1. #1
    Sencha User
    Join Date
    Sep 2009
    Location
    france
    Posts
    4
    Vote Rating
    0
    badenski is on a distinguished road

      0  

    Default Answered: parameter field or property in remote filter with grid and store

    Answered: parameter field or property in remote filter with grid and store


    Hi,

    to avoid managing two param's name in remote script,
    is it possible to give the same param field name to both filters with ExtJS ?

    store filter (Ext.util.Filter)
    param property is used to identify field name
    Code:
    {property: "fieldname",value:"myvalue"}
    grid filter (Ext.ux.grid.FiltersFeature)
    param field is used to identify field name
    Code:
    {field:"fieldname", value:"astring", type:"string"}

  2. Try this:
    Code:
    var store = Ext.create('Ext.data.Store', {
        ...
        remoteFilter: true,
        filters: [{
            property: 'field1', value: 'value1'
        },{
            property: 'field2', value: 'value2'
        }],
        proxy: {
            type: 'ajax',
            ...
            encodeFilters: function(filters) {
                var min = [],
                    length = filters.length,
                    i = 0;
    
    
                for (; i < length; i++) {
                    min[i] = {
                        field: filters[i].property,
                        value: filters[i].value
                    };
                }
                return this.applyEncoding(min);
            }
        }
    });

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    109
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      1  

    Default


    Try this:
    Code:
    var store = Ext.create('Ext.data.Store', {
        ...
        remoteFilter: true,
        filters: [{
            property: 'field1', value: 'value1'
        },{
            property: 'field2', value: 'value2'
        }],
        proxy: {
            type: 'ajax',
            ...
            encodeFilters: function(filters) {
                var min = [],
                    length = filters.length,
                    i = 0;
    
    
                for (; i < length; i++) {
                    min[i] = {
                        field: filters[i].property,
                        value: filters[i].value
                    };
                }
                return this.applyEncoding(min);
            }
        }
    });

  4. #3
    Sencha User
    Join Date
    Sep 2009
    Location
    france
    Posts
    4
    Vote Rating
    0
    badenski is on a distinguished road

      0  

    Default


    I test it and it works quite well !
    Thanks for your answer !

    I've found an alternative solution (comments on FiltersFeature helps me). I override function buildQuery and change key name field by property :

    Code:
    tmp.push(Ext.apply(
        {},
        {property: f.field},
        f.data
        ));
    Last edited by badenski; 6 Sep 2012 at 6:25 AM. Reason: alternative solution

  5. #4
    Sencha User
    Join Date
    Nov 2012
    Posts
    5
    Vote Rating
    0
    GGG65 is on a distinguished road

      0  

    Default


    vietits, your solution solved my problem where my remote filters were not working at all... no idea why, but with your change it finally started working (though in my case it was added to data.Model, not data.Store).

    No idea how it works exactly (or why it doesn't work otherwise), but this was a life-saver. (FiltersFeature didn't work for some reason for me due to a conflict with some form features).

    Thanks!

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar