2013-02-19 3 views
0

Я перехожу из extjs 2.2 в extjs 4.0. Мой код фильтрует мои данные сетки через php (прокси-url), которые POST обрабатывают некоторые поля ext.POST extjs 4 поля для PHP на store.load

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' 
    }] 
}); 

внутр поля (два exemples, слишком много полей):

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?

(приносит извинения за плохой английский)

ответ

0

Это на самом деле проще сейчас, просто использовать store.clearFilter()

store.clearFilter(); 
store.removeAll(); 
store.load(); 
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" 
           } 
         }) 
    }); 

попробовать этот код работает или not.i думаю, что это то, что и хотят

Смежные вопросы