0

我有一个网格和与之关联的复选框。默认情况下,当网格加载时,它会显示所有记录,但我想在选中复选框时过滤它,并在取消选中复选框时加载所有记录。基本上我只想显示解析日期等于“0001-01-01”的网格数据。我在下面给出了复选框代码和网格屏幕截图。

{
    xtype: 'checkboxfield',
    boxLabel: 'Filter by UN-Resolved',
    id:'chkBox',
    handler: function() {
        var store = Ext.getCmp('defGrid').getStore();
        if(Ext.getCmp('chkBox').getValue()){
            store.filterBy([
                {filterFn: function(item) {return item.get('ID') == 'Sales';{console.log(item);}}
            ]);
            if(filter.data.items[0].data.ResolvedDate === '0001-01-01')
                {console.log("I'm inside");}
        });
    }

在此处输入图像描述

4

1 回答 1

0

我终于能够解决这个问题......代码如下......

{
   xtype: 'checkboxfield',
   boxLabel: 'Filter by UN-Resolved',
   id:'chkBox',
   handler: function() {
   var grid = Ext.getCmp('defGrid');
   var checked = Ext.getCmp('chkBox').getValue();                                          

        if(checked){
            if (grid.store!=undefined) {
                    grid.store.filterBy(function(record) {
                        //console.log(record.data.ResolvedDate);
                        return record.data.ResolvedDate === '0001-01-01' ;
                        });
                    grid.getView().refresh();
            }

        }
            else{
                var grid = Ext.getCmp('defGrid');
                grid.store.clearFilter(true);
                grid.getView().refresh();
            }
    }
}
于 2013-10-15T12:16:52.887 回答