【问题标题】:is it possible to set alternate row backcolor on a jqgrid Treegrid是否可以在 jqgrid Treegrid 上设置备用行背景色
【发布时间】:2011-09-24 07:49:47
【问题描述】:

我开始使用 jqGrid Treegrid,但无论如何我都看不到设置替代行背景颜色。这可能吗?

【问题讨论】:

    标签: jquery jqgrid treegrid


    【解决方案1】:

    如果你的意思是altRowsaltclass 参数,那么就不行了。为了准确地在树网格初始化时间(setTreeGrid 内部),一些 jqGrid 参数将被重置。如何查看herealtRows 参数的值将设置为false。如果您想象树节点的扩展/折叠可以更改树项目的顺序,那么更改的原因将很清楚,因此您将拥有

    来自原始树

    已更新:始终存在解决方法。使用以下代码查看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"
    });
    

    【讨论】:

    • 这就是我的全部观点,因为当您展开折叠时,您需要重置 altRow 颜色。你有什么解决方法吗?
    • 谢谢。 .我有点担心这个的性能,但感谢您的更新
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-21
    • 1970-01-01
    • 2011-10-20
    • 2011-09-24
    • 1970-01-01
    相关资源
    最近更新 更多