Z
Z
z00912014-05-30 01:11:31
ExtJS/Sencha
z0091, 2014-05-30 01:11:31

ExtJs 4 save filters in grid on getStore().reload()

Hello!
For grid filters I use ext.ux.grid.filtersfeature.
There is a problem. When the storage is restarted, the filters are reset.
I reload the store like this
Ext.widget('itemslist').getStore().reload();
Filter configuration:

features: [{
        ftype: 'filters',
        autoReload: true,
        encode: true,
        local: false
    }],

store config:
autoLoad: true,
    storeId: 'ItemsStore',
    remoteSort: true,
    remoteFilter:true,
    pageSize: 20,
    proxy: {
        type: 'ajax',
        url: '/items/getlist',
        reader: {
            root: 'data',
            totalProperty: 'totalCount',
            type: 'json'
        },
        simpleSortMode: true
    },
    sorters: [{
        property: 'item_name',
        direction: 'DESC'
    }],
    autoLoad: true

This problem brings a lot of trouble. The grid loaded, filtered - found the desired object, opened the window, edited, saved. Reloaded the store, but the filters were reset. I have to filter again...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
z0091, 2014-05-30
@z0091

Accidentally found the following solution
. Unfortunately, I have to access the object by id.
I can't figure out how to use this.

saveChangeItemConfig: function(button) {
        var data = button.up('form').getForm().getValues();
        console.log(data);

        Ext.Ajax.request({
            url: '/items/changeorcreateconfig',
            method: 'GET',
            params: data,
            scope: this,
            success: function(response, opts) {;
                response = Ext.decode(response.responseText);
                if(response.success==1){
                    Ext.getCmp('items_list_grid').filters.reload();
                }else{
                    Ext.MessageBox.alert('Ошибка','Видимо произошла ошибка!');
                }
            },
            failure: function(response, opts) {
                alert('Ошибка!!');
            }
        });
    },

L
lfs, 2014-10-29
@lfs

saveChangeItemConfig: function(button) {
        var data = button.up('form').getForm().getValues();
        var grid = button.up('gridpanel');
       //лучше сделать уникальный xtype для вашего грида
    //     var grid = button.up('z0091_gridpanel');
        console.log(data);
        console.log(grid);

        Ext.Ajax.request({
            url: '/items/changeorcreateconfig',
            method: 'GET',
            params: data,
            scope: this,
            success: function(response, opts) {;
                response = Ext.decode(response.responseText);
                if(response.success==1){
                    grid.getStore().filters.reload();
                }else{
                    Ext.MessageBox.alert('Ошибка','Видимо произошла ошибка!');
                }
            },
            failure: function(response, opts) {
                alert('Ошибка!!');
            }
        });
    },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question