接听
how to make sort icons visible in all column headers in jqgrid regardless on sort status
介绍如何向列添加可排序指示。
默认排序指示器很难区分已排序列和未排序列。
如何在排序指示器之外的排序列标题文本下划线?
发布于 2012-01-19 01:02:24
我从前面的答案修改了the following的演示,现在显示

我在演示中使用了CSS类,我在其中添加了下划线,更改了文本的颜色
.sortedColumnHeader > div { text-decoration: underline; color: blue; }如果我们向前播放,我们可以只使用“ui-state-highlight”来突出显示(参见another demo)。列标题可能与标准列有太多不同:

相应的代码是
var $grid = $("#list"), colModel, sortName;
// create the grid
$grid.jqGrid({
// all typical jqGrid parameters
onSortCol: function (index, idxcol, sortorder) {
if (this.p.lastsort >= 0 && this.p.lastsort !== idxcol
&& this.p.colModel[this.p.lastsort].sortable !== false) {
// show the icons of last sorted column
$(this.grid.headers[this.p.lastsort].el)
.find(">div.ui-jqgrid-sortable>span.s-ico").show();
$(this.grid.headers[this.p.lastsort].el).removeClass('sortedColumnHeader');
}
$(this.grid.headers[idxcol].el).addClass('sortedColumnHeader');
}
});
// show sort icons of all sortable columns
colModel = $grid.jqGrid('getGridParam', 'colModel');
sortName = $grid.jqGrid('getGridParam', 'sortname');
$('#gbox_' + $.jgrid.jqID($grid[0].id) +
' tr.ui-jqgrid-labels th.ui-th-column').each(function (i) {
var cmi = colModel[i], colName = cmi.name;
if (cmi.sortable !== false) {
// show the sorting icons
$(this).find('>div.ui-jqgrid-sortable>span.s-ico').show();
} else if (!cmi.sortable && colName !== 'rn' && colName !== 'cb' && colName !== 'subgrid') {
// change the mouse cursor on the columns which are non-sortable
$(this).find('>div.ui-jqgrid-sortable').css({cursor: 'default'});
}
if (cmi.name === sortName) {
$(this).addClass('sortedColumnHeader');
}
});最后,我想再引用一个old answer,其中显示了另一个突出显示已排序列的复杂方法。
https://stackoverflow.com/questions/8912253
复制相似问题