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

问题描述

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

解决方案

如果你的意思是 altRowsaltclass 参数,那就不行了.为了准确地在树网格初始化时(在 setTreeGrid 内部),一些 jqGrid 参数将被重置.如何查看:

var resetAltRows = function () {//如果需要,我认为可以稍微提高功能的性能,//但它应该做同样的事情$(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',数据类型:'json',mtype:'GET',colNames:[ID",描述",总计"],col型号:[{name:'id', index:'id', width: 1, hidden: true, key: true},{名称:'desc',宽度:180,可排序:false},{name:'num', width:80, sortable:false, align:'center'}],treeGridModel:'邻接',高度:'自动',//altRows: true,//altclass: 'myAltRowClass',行数:10000,树网格:是的,ExpandColumn:'desc',加载完成:函数(){变格=这个;resetAltRows.call(this);$(this).find('tr.jqgrow td div.treeclick').click(function(){重置AltRows.call(网格);});$(this).find('tr.jqgrow td span.cell-wrapper').click(function(){重置AltRows.call(网格);});},ExpandColClick:真,标题: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?

解决方案

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

from the original tree

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 上设置备用行背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 20:35