Extjs 4.1.3按钮设置有效的过滤器 [英] Extjs 4.1.3 button that sets active filters

查看:152
本文介绍了Extjs 4.1.3按钮设置有效的过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在工具栏上添加一个按钮,自动将过滤器设置为活动状态,然后过滤数据。我尝试使用 setActive()函数 Ext 4.1.3 ,但该函数未被识别。 p>

小提琴



代码

  var openButton = Ext .create('Ext.Button',{
text:'Open Topics',
handler:function(){
grid [uniqueId] .filters.setActive('Open / Current') ;
}
});

...
var columns = [{
text:'Status',
width:100,
dataIndex:'TopicStateValue',
过滤器:{
type:'list',
options:['Open / Current','Archived / Closed','Hold']
}
}
...


解决方案

setActive方法不能在你找到的位置找到它。
您尝试在过滤器列表上执行setActive,但实际的功能只有在找到特定的过滤器对象后才能执行。



您的示例代码(小提琴没有用,因为您跳过了有问题的列),您将首先得到过滤器:

  var filter = grid [uniqueId] .filters.getFilter('TopicStateValue'); 
filter.setActive(true);

但是,激活过滤器不会执行您期望的操作。它将仅在过滤器栏中启用过滤器UI元素。
要在启用该过滤器后自动执行所述过滤器,您需要设置该过滤器的值:

  filter.setValue '打开/电流'); 

如果您不使用过滤器栏或不想显示此特定的过滤器下拉列表您最好直接过滤商店:

  var store = grid [uniqueId] .getStore() ; 
store.filterBy(function(item){
return item.TopicStateValue =='Open / Current';
});


I want to add a button to the toolbar that automatically sets a filter as active and then subsequently filters the data. I have tried using the setActive() function for Ext 4.1.3 but that function is not being recognized.

fiddle

Code

var openButton = Ext.create('Ext.Button', {
            text: 'Open Topics',
            handler: function () {
                grid[uniqueId].filters.setActive('Open/Current');
            }
        });

...
var columns = [{
    text: 'Status',
    width: 100,
    dataIndex: 'TopicStateValue',
    filter: {
        type: 'list',
        options: ['Open/Current', 'Archived/Closed', 'Hold']
    }
}
...

解决方案

The setActive method can't be found in the location you look for it. You're trying to execute setActive on a list of filters, but the actual function can only be executed once you have found the specific filter object.

In your example code (the Fiddle is of no use as you skipped the column in question there) you would get the filter first like this:

var filter = grid[uniqueId].filters.getFilter('TopicStateValue');
filter.setActive(true);

However activating the filter doesn't do what you expect it to do. It will merely enable the filter UI element in the filters bar. To execute said filter automatically after enabling it you need to set the Value for that filter:

filter.setValue('Open/Current');

If you're not using the filters bar or don't want to show this particular filter dropdown to the user at all, you're better off filtering the store directly:

var store = grid[uniqueId].getStore();
store.filterBy(function(item) {
    return item.TopicStateValue == 'Open/Current';
});

这篇关于Extjs 4.1.3按钮设置有效的过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆