【问题标题】:How to highlight the Extjs grid newly inserted row?如何突出显示 Extjs 网格新插入的行?
【发布时间】:2011-09-11 16:03:39
【问题描述】:

知道如何突出显示新插入的行吗?

我尝试使用商店的添加事件,它给了我最后插入的记录和记录索引。

但是如何引用它来突出显示网格行?

这是商店。

Ext.create('Ext.data.Store', {
    model   : 'invoice_model',
    storeId : 'invoice_store',
    proxy   : {
        type: 'memory'
    },
    listeners   : {
        add : function(s, r, i){
            console.log(r)  

        }
    }
});

问候

【问题讨论】:

    标签: javascript extjs extjs4


    【解决方案1】:

    假设“i”是网格上记录的索引(因此,网格中行的索引):

        Ext.fly(myGrid.getView().getNode(i)).highlight("highlight color", {
                attr: 'color', duration: 5000 
            });
    

    但是,如果插入的记录总是在第一行,您可以在添加记录后指定第一行:

        Ext.fly(myGrid.getView().getNode(0)).highlight("highlight color",{ 
                  attr: 'color', duration: 5000 
              });
    

    要突出显示行的背景颜色,可以在新插入的行中添加一个突出显示类:

    CSS:

       .myHighlight{
           background : your-highlight-color
       }
    

    JS

       Ext.fly(myGrid.getView().getNode(0)).addCls("myHighlight");
    

    然后在完成突出显示后将其删除:

      Ext.fly(grid.getView().getNode(0)).removeCls("myHighlight");
    

    【讨论】:

      【解决方案2】:

      在您的添加功能中,尝试
      Ext.fly(myGrid.getView().getNode(r.getId())).highlight("0000ff", { attr: 'color', duration: 2 });

      将高亮配置更改为您的偏好

      编辑

      Store 的 add 事件为我们提供了一组已添加的记录。如果要突出显示所有这些,请遍历数组并为数组中的每条记录调用上面的 sn-p。如果您想突出显示特定的(可能是第一个或最后一个),请从数组中获取它并调用上面的 sn-p。在上面的 sn-p 中,r 指的是一个特定的记录。

      【讨论】:

      • 感谢您的回答,尝试过,我在 firebug r.getId is not a function 中遇到错误
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-26
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-15
      相关资源
      最近更新 更多