2

私はjqGrid Treegridをいじり始めていますが、代替行のバックカラーを設定する方法がわかりません。これは可能ですか?

4

1 に答える 1

3

パラメータを意味する場合、機能しませaltRowsん。altclass正確にツリー グリッドの初期化時間 (の内部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"
});
于 2011-06-28T16:04:15.877 に答える