【问题标题】:Unchecking an ExtJS Grid Filter checkbox doesn't remove the filter取消选中 ExtJS 网格过滤器复选框不会删除过滤器
【发布时间】:2015-09-23 12:23:29
【问题描述】:

我使用了功能 - 网格面板的过滤器,像这样使用本地设置为 true

            ftype: 'filters',
            local: true     

应用过滤器并在文本字段中尝试自动启用过滤器复选框并过滤网格。

取消选中过滤器旁边的复选框不会删除过滤器,复选框会消失但网格仍显示过滤后的记录。

如果我删除文本字段中的所有内容,则会显示所有记录。

编辑

这是列、商店和模型的示例。我只包含了公司字段、模型和商店项目的示例......商店确实在填充网格并且过滤器第一次工作但我无法删除过滤器。

 var columns = [{
            header: 'Company',
            minWidth: 200,
            dataIndex: 'company',
            stateId: 'company-stateid',
            draggable: false,
            flex: 10,
            sortable: true,
            doSort: oMe.performSort,
            filter:
            {
                type: 'string'
            }

Ext.define('APEX.model.CompanyModel', {
    extend: 'Ext.data.Model',
    fields: [
        {name:'company', sortType:Ext.data.SortTypes.asUCString},

Ext.define('APEX.store.Company', {
    extend: 'Ext.data.Store',
    model: 'APEX.model.CompanyModel',

Ext.apply(me, {
            store: mainStore,
            columns: columns,
            selModel: {
                selType: 'rowmodel'
            },

【问题讨论】:

  • 您是手动取消选中该框,还是以编程方式?
  • 手动,默认,没有任何改变。使用 extjs 4.2。
  • 我无法复制它,至少不能使用该信息。在一个简单的网格上,在文本字段中启用过滤器功能,删除复选框绝对会为我删除过滤器。商店、列或网格的配置必须存在问题。也许更多代码会有所帮助。
  • 是的,没问题。让我更新故事...
  • 已更新,我想我似乎做的一切都正确。

标签: javascript extjs extjs4 extjs4.2


【解决方案1】:

我之前也遇到过像你这样的问题,我用这个配置解决了:

//This is my model, you can use type if your field not a string...
Ext.define('EKOJS.model.m_mst_pemohon', {
    extend: 'Ext.data.Model',
    alias       : 'widget.mst_pemohonModel',
    fields      : [{name: 'id_pemohon',type:'int'},'NIP','Nama_Pemohon','Telp','Email'],
    idProperty  : 'id_pemohon'  
});

//this is my column in the grid
this.columns = [
{
    header: 'id_pemohon',filterable:true,
    dataIndex: 'id_pemohon',hidden:true
},{
    header: 'NIP',filterable:true,
    dataIndex: 'NIP'
},{
    header: 'Nama_Pemohon',filterable:true,
    dataIndex: 'Nama_Pemohon'
},{
    header: 'Telp',filterable:true,
    dataIndex: 'Telp'
},{
    header: 'Email',filterable:true,
    dataIndex: 'Email'
}];

// This is for grid filtering feature
this.features = [{
        ftype: 'filters',
        autoReload: true,
        encode: false,
        local: true
    }
];

如果你的问题,你可以改变你的配置,不要忘记调整你的模型:

var feature = [{
        ftype: 'filters',
        autoReload: true,
        encode: false,
        local: true
    }
];

var columns = [{
    header: 'Company',
    minWidth: 200,
    dataIndex: 'company',
    stateId: 'company-stateid',
    draggable: false,
    flex: 10,
    sortable: true,
    doSort: oMe.performSort,
    filterable:true

Ext.define('APEX.model.CompanyModel', {
    extend: 'Ext.data.Model',
    fields: [
        {name:'company', sortType:Ext.data.SortTypes.asUCString},

Ext.define('APEX.store.Company', {
    extend: 'Ext.data.Store',
    model: 'APEX.model.CompanyModel',

Ext.apply(me, {
            store: mainStore,
            columns: columns,
            feature: feature,
            selModel: {
                selType: 'rowmodel'
            },

希望这对你也有帮助.. :D

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-12
    • 1970-01-01
    相关资源
    最近更新 更多