1. #1
    Ext User
    Join Date
    Oct 2008
    Posts
    29
    Vote Rating
    0
    jackiewkc is on a distinguished road

      0  

    Default How to filter data in json store

    How to filter data in json store


    Hi,

    I have created a json store called hostStore which contains two fields, one is called environment and the other one is called hostname. I have binded it to a GridPanel which shows only the hostName field like this:

    new Ext.grid.GridPanel({
    store: hostStore,
    cm: new Ext.grid.ColumnModel([
    new Ext.grid.RowNumberer(),
    {id:'hostid',header: "Hostname", width: 40, sortable: true, dataIndex: 'hostName'}
    ]),
    viewConfig: {
    forceFit:true
    },
    columnLines: true,
    height:200,
    iconCls:'icon-grid'
    })

    Now I want it to show only those hostName with environment = "development" so I change the store: line above to:

    store: hostStore.filter('environment', 'development', true, true)

    However this doesn't work, can someone please advise?

    Thanks.

    Regards,
    Jackie

  2. #2
    Ext User
    Join Date
    Oct 2008
    Posts
    29
    Vote Rating
    0
    jackiewkc is on a distinguished road

      0  

    Default


    anyone got any idea? thanks.

  3. #3
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750
    Vote Rating
    7
    fay will become famous soon enough fay will become famous soon enough

      0  

    Default


    Put the GridPanel's store config back to the way it was (store: hostStore) and add a 'load' handler for hostStore:

    PHP Code:
    hostStore.on('load', function(storerecordsoptions)
    {
      
    store.filter('environment''development'truetrue);
    }); 

  4. #4
    Ext User
    Join Date
    Oct 2008
    Posts
    29
    Vote Rating
    0
    jackiewkc is on a distinguished road

      0  

    Default


    Hi fay,

    Thank you so much for the information. I have changed it back to store: hostStore and added the function you suggested. However, I still haven't managed to get it worked. Basically I copied the function you suggested (the whole thing without any change) outside new Ext.grid.GridPanel, just right below it. is there anything else I have to change? and I assume option and record are not some sort of pseudo code, right?

    I am quite new to extjs, thanks a lot for your help.

    Regards,
    Jackie

  5. #5
    Ext User
    Join Date
    Oct 2008
    Posts
    29
    Vote Rating
    0
    jackiewkc is on a distinguished road

      0  

    Talking


    Hi fay,

    Just wanna let you know that I got it sorted. I typed the name of the store wrong. Thanks again for your help. I really appreciate it.

    Regards,
    Jackie

  6. #6
    Sencha User
    Join Date
    Aug 2008
    Posts
    27
    Vote Rating
    0
    sanjaybh is on a distinguished road

      0  

    Default


    Hi guys,

    Can anyone help me regarding the Jsonstore filtering, I have 2 combos, i am filling both the stores of the combos at the loading of the page, but after choosing the value from the first combo, the second dropdown need to get filtered.

    vm.store.filter('custnbr', combo.getValue());

    the problem with this is filter is filtering the same kind of values like, if i choose id 1 it will return all the values that start with 1 means 1, 11, 10 etc that is wrong for me. Is there any option where there is some strict policy of filtering those values that we pass.


    regds,
    sb

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    Use:
    Code:
    vm.store.filterBy(function(r){
      return r.get('custnbr') == combo.getValue();
    });
    ps. Don't forget to configure the vm combobox with:
    Code:
    triggerAction: 'all',
    lastQuery: ''
    (otherwise typing in the combobox will replace the filter for text searching)

  8. #8
    Ext User
    Join Date
    Apr 2009
    Posts
    16
    Vote Rating
    0
    Flonq is on a distinguished road

      0  

    Question Why is filter working only explicitly in load() ?

    Why is filter working only explicitly in load() ?


    I have a related uhm, what looks to me like an oddity:
    My Store (connected to a GridPanel not show) basically works, including filtering when done like this (type is one of 'warn','info','error):

    Code:
    // stores ALL log entries received
        var store = new Ext.data.Store({
            id: 'myStore',
            proxy: proxy,
            reader: reader,
            autoLoad: false, // do below *after* setting filters
            listeners: {
                load: function( thiz, records, o ) { 
                    console.info( "number of entries: " + records.length );
                    Ext.iterate( records,
                        function( item, index ) {
                            console.info( "index " + index+":" 
                                    +item.id + " - " + item.data.type + 
                                    " - " + item.data.msg );
                        }
                    );
                    
                    store.filter('type', 'warn', true, true );                
                }, //load
            }, // listeners
        });
    
        store.load();
    HOWEVER, if I move the store.filter... command out of the callback routine and right in front of store.load(), the filter is no longer effective. ALL entries get shown.

    How is that? How do I actively set a filter after construction. (the store.load() does get executed as I can verify by an adjacent console.info() if I wish...

    Thanx!

  9. #9
    Ext User
    Join Date
    Aug 2009
    Posts
    588
    Vote Rating
    1
    Mike Robinson is on a distinguished road

      0  

    Default


    What I would do is... make the host do it. Add an element, say, to the "baseParam" attribute of the Store object, then make a load() request.

    Here's why: only the host truly knows what records, among the perhaps thousands of records in the underlying database, should be displayed. Therefore, only the host is "in the best position to" perform the filtering. There's no good reason even to transmit records that do not qualify "across the wire" between the two computers.

    After all, the first qualifying record might be on "page 6 of 143" and the next might be on "page 82." What's the client to do... transfer 82 pages' worth of records that it's not interested in, just so the client can throw them away? Heck no. Tell the host what you want, and let it send you only what you're interested in... only the pageful of information that you say you want, from the appropriately-filtered set of records, "filtered" by your friendly neighborhood (host side) SQL server. One page (or however many) of records, containing just what you said you wanted to see. ("Just doin' my job, ma'am...")

  10. #10
    Ext User
    Join Date
    Apr 2009
    Posts
    16
    Vote Rating
    0
    Flonq is on a distinguished road

      0  

    Cool


    Uhm, no. Not my use case. The number of data sets is small.
    And convenient. My store could be a simpleStore if I wanted to.

    I need filtering not for keeping network traffic down, but to only show the user the type of messages he wants (e.g. either of type 'warn' or of type 'info' or just all of them...). There's no good reson to ask the host again between these changes of view. Maintaining all info on the client is fine.

    Perhaps I did not understand the workflow.
    Should I first load, then filter (presuming after the object is constructed) or
    is it first setting a filter, then load from the proxy?

    Do I need to refresh the store afterwards? Or refresh the grid, maybe?

    Even a filterBy function does not even get called (as I can tell from console.info):

    Code:
    ...
                }, // listeners
        });
    
        store.load();
        store.filterBy(
            function( record, id ) {
                     // I of course don't expect filtering from this
                     // but I do expect console output
                     console.info( "record called for id " + id );
                     return true;
            });
        store.load();
    
        grid = new Ext.grid.GridPanel({
            // rendering
            renderTo: 'xgrid',
              ...
            },
        });
        
        grid.store.reload(); // no luck either

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