0

我正在从 extjs 2.2 迁移到 extjs 4.0。我的代码通过 POST 一些 ext 字段的 php(代理 url)过滤我的网格数据。

etx商店:

var store = Ext.create('Ext.data.Store', {
    model: 'Company',
    remoteSort: true,
    remoteFilter: true,
    proxy: {
        // load using script tags for cross domain, if the data in on the same domain as
        // this page, an HttpProxy would be better
        type: 'ajax',
        url: "logica_de_aplicacao/usuario/grid_usuarios_dados.php",
        reader: {
            root: 'results',
            totalProperty: 'total'
        },
        // sends single sort as multi parameter
        simpleSortMode: true
    },
    sorters: [{
        property: 'nome',
        direction: 'ASC'
    }]
});

ext字段(两个例子,字段太多):

var txtLogin = new Ext.form.TextField({
                    fieldLabel: "Login",
                    width: 200
                });

var txtAtivo = new Ext.form.ComboBox({
                    fieldLabel: 'Ativo',
                    width: 200,
                    name: 'ativo',
                    editable: false,
                    disableKeyFilter: true,
                    forceSelection: true,
                    triggerAction: 'all',
                    mode: 'local',
                    store: new Ext.data.SimpleStore({
                        id: 0,
                        fields: ['value', 'text'],
                        data : [['S', 'Sim'], ['N', 'Não']]
                    }),
                    valueField: 'value',
                    displayField: 'text',
                    hiddenName: 'ativo'
                });

过滤:

tbar: [{
        text: "Adicionar Filtro", //add filter
        tooltip: "Filtre os resultados",
        iconCls:"icone_filtro",
        handler: function() {
            iniciaPesquisa();
        }
    }, {
        text: "Remover Filtro", //remove filter
        tooltip: "Cancelar o filtro",
        iconCls:"icone_cancel_filtro",
        handler: function() {
            store.baseParams = {
                login: "",
                nome: "",
                privilegio: "",
                ativo: "",
                municipio: ""
            };
            store.removeAll();
            store.load();

        }
    }],

PHP:

...
$login = $_POST["login"];
...
$ativo = $_POST["ativo"];

在 ext 2.2 中,通常会在 store.load() 操作上发布字段内容,但现在什么也没有发生。我如何在 ext 4 中发布这些字段?

(为糟糕的英语道歉)

4

2 回答 2

0
var store = Ext.create('Ext.data.Store', {
    model: 'Company',
    remoteSort: true,
    remoteFilter: true,
    proxy: {
        // load using script tags for cross domain, if the data in on the same domain as
        // this page, an HttpProxy would be better
        type: 'ajax',
        url: "logica_de_aplicacao/usuario/grid_usuarios_dados.php",
baseParams: {  //here you can define params you want to be sent on each request from this store
                        login: "",
                nome: "",
                privilegio: "",
                ativo: "",
                municipio: ""
                        },
        reader: {
            root: 'results',
            totalProperty: 'total'
        },
        // sends single sort as multi parameter
        simpleSortMode: true
    },
    sorters: [{
        property: 'nome',
        direction: 'ASC'
    }]
});

tbar: [{
        text: "Adicionar Filtro", //add filter
        tooltip: "Filtre os resultados",
        iconCls:"icone_filtro",
        handler: function() {
            iniciaPesquisa();
        }
    }, {
        text: "Remover Filtro", //remove filter
        tooltip: "Cancelar o filtro",
        iconCls:"icone_cancel_filtro",
        id : 'BtnRemoveFilter', // added this
        handler: function() {
            store.baseParams = {
                login: "",
                nome: "",
                privilegio: "",
                ativo: "",
                municipio: ""
            };
            store.removeAll();
            store.load();

        }
    }],

var Btn = Ext.getCmp('BtnRemoveFilter');
    Btn.on('click', function(){
        store.load({
                        params: {  //here you can define params on 'per request' basis
                                login: "the value u want to pass",
                nome: "the value u want to pass",
                privilegio: "the value u want to pass",
                ativo: "the value u want to pass",
                municipio: "the value u want to pass"
                                }
                        })
    });

试试这段代码是否有效。我认为这就是你想要的

于 2013-02-19T15:15:49.040 回答
0

现在实际上更简单了,只需使用store.clearFilter()

store.clearFilter();
store.removeAll();
store.load();
于 2013-02-19T14:57:42.673 回答