Javascript 突出显示GridPanel Ext.net(ExtJS)中的一组行

Javascript 突出显示GridPanel Ext.net(ExtJS)中的一组行,javascript,asp.net,extjs,ext.net,Javascript,Asp.net,Extjs,Ext.net,需要高亮显示Ext.netgridPannel颜色中需要高亮显示的一组行 当前方法是在渲染GridPannel时调用以下函数: function (value, meta, record, rowIndex,columnIndex,store) { color= record.data["ColorValue"]; var style = document.createElement('style');

需要高亮显示Ext.net
gridPannel
颜色中需要高亮显示的一组行

当前方法是在渲染GridPannel时调用以下函数:

 function (value, meta, record, rowIndex,columnIndex,store) 
    {

                    color= record.data["ColorValue"];
                    var style = document.createElement('style');
                    style.type = 'text/css';
                    style.innerHTML = '.cssClass'+rowIndex+' {   background color:'+color+'}';
                    document.getElementsByTagName('head')[0].appendChild(style);
                    grid.store.getAt(rowIndex).set("mySelected", "cssClass"+rowIndex);
    }
但是使用这种方法:它将突出显示具有相同颜色的所有行。。测试<代码>警报(颜色)从GridPannel中获取每种颜色的正确不同颜色


有什么好方法吗?

您可以在GridView中重写getRowClass方法

new Ext.grid.GridPanel({
    [...],
    viewConfig: {
        getRowClass: function(record, index, rowParams, store) { return 'some-class'; }
    }
});
或者,如果需要在渲染后应用颜色,可以尝试为每行设置:

grid.getView().getRow(0).className += 'some-class';

注意:此示例基于ExtJS 3.4 API,但我打赌4.0中也有类似的内容。

您可以在GridView中重写getRowClass方法

new Ext.grid.GridPanel({
    [...],
    viewConfig: {
        getRowClass: function(record, index, rowParams, store) { return 'some-class'; }
    }
});
或者,如果需要在渲染后应用颜色,可以尝试为每行设置:

grid.getView().getRow(0).className += 'some-class';

注意:此示例基于ExtJS 3.4 API,但我敢打赌4.0中也有类似的内容。

对于ExtJS 4,您可以使用网格存储中记录的排序方法

var store = grid.getStore();
var view  = grid.getView();
var node;

store.each(function(record) {
    if (record.get('fieldname') !== 'your_condition') return;

    //Return the node given the passed Record, or index or node.
    node = view.getNode(record);
    if (!node) return;

    Ext.get(node).highlight();
});

使用ExtJS4,您可以使用网格存储中记录的方法

var store = grid.getStore();
var view  = grid.getView();
var node;

store.each(function(record) {
    if (record.get('fieldname') !== 'your_condition') return;

    //Return the node given the passed Record, or index or node.
    node = view.getNode(record);
    if (!node) return;

    Ext.get(node).highlight();
});