是否可以阻止JQGrid行被选中和/或突出显示?
-
23-09-2019 - |
题
我看了看 文档 但是我一直找不到答案。是否有一种方法可以防止选择时突出显示?这甚至是一种完全阻止选择的行。我喜欢“ Hoverrows:true”选项,但理想情况下,我想阻止一行在单击中选择。
谢谢,
更新:我已经能够“ hackily”实现似乎是临时修复的东西。我一点都不喜欢它,如果有一个...
我发现,如果我通过了选项
onSelectRow: function(rowid, status) {
$('#'+rowid).removeClass('ui-state-highlight');
}
当我实例化JQGrid时,添加亮点时可以将其剥离。
还有另一种理想的方法吗?
解决方案
使用以下代码:
beforeSelectRow: function(rowid, e) {
return false;
}
其他提示
如果您像我一样拥有一定数量的jqgrids,并且不想为每一个jqgrids覆盖Onselectrow,那么这是Reigel的全球版本的Reigel解决方案,对我来说很好:
jQuery.extend(jQuery.jgrid.defaults, {
onSelectRow: function(rowid, e) {
$('#'+rowid).parents('table').resetSelection();
}
});
我想您可以直接在CSS中解决此问题。只需覆盖特定表的UI状态高光的值
#table_id tr.ui-state-highlight {
border: inherit !important;
background: inherit !important;
color: inherit !important;
}
#table_id tr.ui-state-highlight a {
color: inherit !important;
}
#table_id tr.ui-state-highlight .ui-icon {
background-image: inherit !important;
}
我使用了该值 inherit
例如 - 您可能需要从theme.css复制一些值才能完成此工作。
尝试:
onSelectRow: function(rowid, status) {
$("#grid_id").resetSelection(); //Resets (unselects) the selected row(s). Also works in multiselect mode.
}
您可以阅读文档 这里. 。希望它能帮助您...
是的,使用rowattr回调:
rowattr: function (rowData,currentObj,rowId) {
if (rowData.SomeField=="SomeValue") {
return {"class": "ui-state-disabled"};
}
},
这也符合行并禁用选择。
不隶属于 StackOverflow