【问题标题】:POST extjs 4 fields to PHP on store.load在 store.load 上将 extjs 4 字段发布到 PHP
【发布时间】:2013-02-19 12:56:27
【问题描述】:

我正在从 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 中发布这些字段?

(为糟糕的英语道歉)

【问题讨论】:

    标签: php post extjs filter extjs4


    【解决方案1】:

    现在其实更简单了,直接用store.clearFilter()

    store.clearFilter();
    store.removeAll();
    store.load();
    

    【讨论】:

      【解决方案2】:
      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"
                                      }
                              })
          });
      

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

      【讨论】:

        猜你喜欢
        • 2015-11-21
        • 2014-10-12
        • 2013-07-07
        • 2012-08-12
        • 2012-12-14
        • 2012-04-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多