根据排序或不排序更改光标样式 [英] Change cursor style depending on sort or not
问题描述
我使用jqGrid并有3列不能排序。此时,无论将排序设置为true还是false,当用户将鼠标悬停在标题上时,光标会变为一只手。我希望光标不是那些列头上的手(文本或指针)。用这种方式让用户感到困惑。这是可以设置的东西?
谢谢,
Mark
你不是第一个希望在不可排序列上有另一个游标的人(也不是最后一个人)。遗憾的是,jqGrid并没有给你类或其他一些简单的属性,它们可以用来查找可以设置CSScursor:default的元素。
我建议使用以下代码来完成此操作:
var myGrid = $(#list);
//创建网格
myGrid.jqGrid({
//所有jqGrid参数
});
//将光标固定在不可排序的列上
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});
}
});
你可以在该演示文稿生活的方法工作。在演示中,最后一列'Notes'是不可排序的。
如果这种行为在下一个版本的jqGrid中是标准的,那将会很好。我会尽量找出时间并写出建议,应该改变jqGrid的代码,使其成为开箱即用的行为。
更新:在不可排序列上的游标问题在 free jqGrid 4.8 。
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?
Thanks, Mark
I find the question very good. So +1 from me.
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"});
}
});
You can see on the demo live that the method work. In the demo the last column 'Notes' is non-sortable.
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.
UPDATED: The problem with the cursor on non-sortable columns is not exist more in free jqGrid 4.8.
这篇关于根据排序或不排序更改光标样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!