根据排序或不更改光标样式
我正在使用 jqGrid 并且有 3 列无法排序.此时,无论排序设置为 true 还是 false,当用户将鼠标悬停在标题上时,光标都会变为手形.我希望该光标不是那些列标题上的手(文本或指针).这种方式让用户感到困惑.这是可以设置的吗?
I'm using the jqGrid and have 3 columns that can NOT be sorted. At this point the cursor changes to a hand when the user hovers over the headers regardless of sorting set to true or false. I'd like that cursor to be something other than a hand (text or pointer) on those column heads. It's confusing to the users this way. Is this something that can be set?
谢谢,标记
推荐答案
我觉得这个问题很好.所以我要 +1.
I find the question very good. So +1 from me.
您不是第一个(也不是最后一个)希望在不可排序的列上有另一个光标的人.很遗憾,但 jqGrid 没有为您提供类或其他一些简单的属性,这些属性可用于查找可以设置 CSS "cursor:default" 的元素.
You are not the first person (and not the last one) who wish to have another cursor on non-sortable columns. It's pity, but jqGrid gives you not classes or some other simple attributes which can be used to find the elements at which one can set CSS "cursor:default".
所以我建议使用以下代码:
So I suggest to do this with the following code:
var myGrid = $("#list");
// create the grid
myGrid.jqGrid({
// all jqGrid parameters
});
// fix cursor on non-sortable columns
var cm = myGrid[0].p.colModel;
$.each(myGrid[0].grid.headers, function(index, value) {
var cmi = cm[index], colName = cmi.name;
if(!cmi.sortable && colName!=='rn' && colName!=='cb' && colName!=='subgrid') {
$('div.ui-jqgrid-sortable',value.el).css({cursor:"default"});
}
});
您可以在 demo 现场看到该方法有效.在演示中,最后一列Notes"是不可排序的.
You can see on the demo live that the method work. In the demo the last column 'Notes' is non-sortable.
如果这种行为在 jqGrid 的下一个版本中成为标准,那就太好了.我会尽量找时间写建议,应该从 jqGrid 的代码中更改哪些内容以使行为开箱即用.
It would be nice if such behavior would be standard in the next version of jqGrid. I will try to find time and to write suggestion what from the code of jqGrid should be changed to make the behavior out-of-the-box.
更新:在 免费 jqGrid 4.8.
相关文章