根据数据设置Dojox Grid行的样式

6
我正在尝试根据网格中的值来设置DojoX(1.2.3)网格内部的行样式。
GridLayout:
var view1 = {
                noscroll: true,
                rows: [{
                    field: 'TASK_ID',
                    name: 'ID',
                    width: '80px',
                    get: this.getColor
                }, {
                    field: 'MENUPOINT',
                    name: 'Action',
                    width: '250px'
                }]
            };

颜色函数:
 getColor: function(inRowIndex) {
        console.log(inRowIndex);
        grid = dijit.byId('gridTaskCurrent');
            // if task_id = 1 style row with other background(?)
        },

我不知道如何从每一行获取task_id值并为该行设置样式。如果有人有好的链接或知道如何做,那就太好了。
1个回答

10

我自己解决了:

dojo.connect(dijit.byId('gridTaskCurrent'), 'onStyleRow' , this, function(row) {
                   var item = grid.getItem(row.index);

                    if (item) {
                        var type = grid.store.getValue(item, "LOCKED", null);
                        if (type == 1) {
                            row.customStyles += "background-color:limegreen;";
                        }
                    }

                    grid.focus.styleRow(row);
                    grid.edit.styleRow(row);


                });

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接