繁体   English   中英

如何从ExtJS TableStore中的表格单元格中获取渲染值

[英]How do I get the rendered value from a table cell in ExtJS TableStore

我正在构建一个过滤函数,可以过滤我表格中的所有单元格。

为此,我正在遍历我的tablestore并访问我的每个记录项字段,就像这样。

tablestore.each(function (rec, idx) {
    contains = false;

    for (field in rec.data) {

        var cellValueAsString = "" + rec.data[field]
    }
}

我的问题是:如何获取用户在HTML页面中看到的渲染值?

我有许多渲染器,例如日期渲染器,以及从状态编号创建字符串的渲染器。

上面代码中的值cellValueAsString只返回基础值,而不是显示的值。 有没有办法从tableStore和/或rec对象访问显示的值?

thhx!

每个Grid列都有一个名为renderer的属性,它是一个函数。 然后你的任务就是实现这个功能。 为此你可以在某个地方构建一个数组(map fieldName => renderer)并在你的网格和新地方或仅在你的新地方调用它。

请试试这个

将itemclick侦听器添加到网格中,如下所示

listeners:{
            itemclick: this.getRowItem,
            scope:this
        }

将tdCls添加到要从中检索显示值的列。如下所示

{ 
   text: 'Name',  
   dataIndex: 'name',
   renderer: function(value, metadata, record){

        return value+" hello";

        },
        tdCls:'name-render'

    }

你的函数getRowItems应该如下所示

getRowItem: function(gridPanel, record, item, index, e, eOpts){


   var tdItem= item.getElementsByClassName('name-render');
   var actualTextDisplayed = tdItem.firstChild.innerHTML;
   return actualTextDisplayed ;

}

我认为这是另一种选择。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM