是否可以在jqgrid Treegrid上设置备用行背景色

时间:2011-06-28 13:20:20

标签: jquery jqgrid treegrid

我开始玩jqGrid Treegrid,但我还是没有看到设置备用行背颜色。这可能吗?

1 个答案:

答案 0 :(得分:3)

如果您指的是altRowsaltclass参数,则无效。要准确地在树网格初始化时间(setTreeGrid内),将重置一些jqGrid参数。如何查看here altRows参数的值将设置为false。如果你想象树节点的扩展/折叠可以改变树项的顺序,那么改变的原因就很清楚了

enter image description here

来自原始树

enter image description here

更新:始终存在变通方法。请参阅以下代码the demo

var resetAltRows = function () {
    // I think one can improve performance the function a little if needed,
    // but it should be done the same
    $(this).children("tbody:first").children('tr.jqgrow').removeClass('myAltRowClass');
    $(this).children("tbody:first").children('tr.jqgrow:visible:odd').addClass('myAltRowClass');
};
$("#tree").jqGrid({
    url: 'AdjacencyTreeAltRows.json',
    datatype:'json',
    mtype:'GET',
    colNames: ["ID", 'Description', "Total"],
    colModel: [
        {name:'id', index:'id', width: 1, hidden: true, key: true},
        {name:'desc', width:180, sortable:false},
        {name:'num', width:80, sortable:false, align:'center'}
    ],
    treeGridModel:'adjacency',
    height:'auto',
    //altRows: true,
    //altclass: 'myAltRowClass',
    rowNum: 10000,
    treeGrid: true,
    ExpandColumn:'desc',
    loadComplete: function() {
        var grid = this;
        resetAltRows.call(this);
        $(this).find('tr.jqgrow td div.treeclick').click(function(){
            resetAltRows.call(grid);
        });
        $(this).find('tr.jqgrow td span.cell-wrapper').click(function(){
            resetAltRows.call(grid);
        });
    },
    ExpandColClick: true,
    caption:"TreeGrid Test"
});