0
votes

I'm having really hard time to understand or maybe more correct will be to say - to use filters on any of my store and loading the info in the grid. I have a more complex task but in order to understand how things work I decided to use as most simple example as I could just to see how things happen and then to add more logic so I can grind my knowledge. However still I don't get any encouraging results so I'm again asking for help.

I have a gridPanel in my model which use his own store, in this case :

"RecordsListStore"

And I have

xtype: combo;

which looks like this:

            xtype: 'combo',
            id: 'records_list_author_id',
            emptyText: 'Филтриране по автор',
            editable: false,
            store: 'Users',
            displayField: 'firstname',
            valueField: 'id',
            lastQuery: '',
                        triggerAction: 'all',
                        queryMode: 'remote',
                        typeAhead: false,
            width: 200,
            listeners: {
                          select: this._filterRecords
                   }

Which uses it's own store to load data in the combobox which could be selected from the user.

The thirs part, the select function is:

_filterRecords: function()
    {
        var recStore =  Ext.getStore('FilterRecordsByAuthor');
        var a = Ext.getCmp('records_list_author_id').getValue( );
        var rec = Ext.getStore('FilterRecordsByForm').getAt(a);
        recStore.filters.clear();
            //recStore.load();
        recStore.filter([{
            "property":'form_id',
            "value": 1
                   }]);
        console.log(recStore.load());
    },

Here comes a third store which I think to use for fetching the the filtered data. The problem is that the console log shows that I send the filters but everytime I get empty result. But if everything works as I thought it should there must me some info, so there's mistake or something missing, but I can't figure out what should be done.

1
So using this _filterRecords: function() { var a = Ext.getCmp('records_list_author_id').getValue( ); var rec = Ext.getStore('RecordsListStore'); rec.filters.clear(); rec.filter([{ "property":'author_id', "value": a }]); console.log(a); },I get things working now the grid is loaded with the info, I just needed to add $data['filter'] in my SQL query but now I want to relod the store without filters any ideas?I try this handler: function() { var rec = Ext.getStore('RecordsListStore'); rec.load(); } but no success - Leron_says_get_back_Monica

1 Answers

1
votes

getValue() of combobox will give you value from the combobox not index in the store. So after you got this value you need to actually look record up with something like store.findExact('some_field', value) and only after that getAt() with the index you got.