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

发布于 2024-12-18 02:59:43 字数 753 浏览 1 评论 0原文

需要以 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);
    }

但是使用这种方法:它突出显示所有行具有相同的颜色 .. 测试 alert(color); 从 GridPannel 中获取每种颜色的正确不同颜色

有什么好的方法吗?

Required to highlight set of rows in a Ext.net gridPannel color which required to highlight

Current approach is to call the below function on rendering the 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);
    }

But with this approach: it highlights all the rows with the same color .. a test alert(color); fetched the correct different color of each color from the GridPannel

Any Good approach for this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酷到爆炸 2024-12-25 02:59:43

您可以重写 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 中有类似的东西。

You can override getRowClass method in GridView.

new Ext.grid.GridPanel({
    [...],
    viewConfig: {
        getRowClass: function(record, index, rowParams, store) { return 'some-class'; }
    }
});

Or if you need apply colors post-render, you can try setting for each row:

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

Note: this examples are based on ExtJS 3.4 API, but i bet there is something similiar in 4.0.

智商已欠费 2024-12-25 02:59:43

使用 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();
});

With ExtJS 4 you can use the highlight method of the row element of the records in the grid store.

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();
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文