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

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

如果你的意思是altRowsaltclass参数,那么就没有用。 要准确地在树网格初始化时间(在setTreeGrid内部),将重置一些jqGrid参数。 如何在这里看到altRows参数的值将设置为false 。 如果你想象树节点的扩展/折叠可以改变树项的顺序,那么改变的原因就很明显了所以你会有

在此处输入图像描述

从原始的树

在此处输入图像描述

更新 :解决方法始终存在。 使用以下代码查看演示 :

 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" });