Treegrid上设置备用行背景色

Treegrid上设置备用行背景色

本文介绍了是否可以在jqgrid Treegrid上设置备用行背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始尝试使用jqGrid Treegrid,但无论如何我都看不到设置其他行背景色.这可能吗?

i am starting to play around with jqGrid Treegrid but i don't see anyway to set alternative row back color. Is this possible?

推荐答案

如果您指的是altRowsaltclass参数,则该方法无效.为了恰好在树形网格初始化时间(在setTreeGrid内部),将重置一些jqGrid参数.您如何在此处看到altRows参数的值将设置为false.如果您想象扩展/折叠树节点可以更改树项目的顺序,那么更改的原因就很清楚了

If you mean altRows and altclass parameters, then there not works. To be exactly at the tree grid initialization time (inside of setTreeGrid) some jqGrid parameters will be reset. How you can see here the value of the altRows parameter will be set to false. The reason of the change would be clear if you imagine that expanding/collapsing of tree nodes can change the order of the tree items so you would be have

来自原始树

已更新:始终存在一种解决方法.请参见演示,其中包含以下代码:

UPDATED: A workaround is always exist. See the demo with the following code:

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

这篇关于是否可以在jqgrid Treegrid上设置备用行背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:32