1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    2
    Vote Rating
    0
    MrBuzzy is on a distinguished road

      0  

    Default Filtering: One store, multiple lists

    Filtering: One store, multiple lists


    Hello, I'm pretty new to Sencha and I'm just not understanding how to do this, perhaps someone could shed some light.

    I have an auto-loading Store that contains a bunch of records. Then, I have a few tabs that each contain a list.

    I would like each list to display a 'filtered' view of the data within the store. For example, list1 displays filtered store data and list2 displays a different filtered view of the store.

    How can I add different filters for different views? Do I need to create a store for each list view?

    I looked into adding the filter to the Store config, but this filters on the entire store, not useful for creating sub-views of the original store data.

    Many thanks.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Since you will only have 1 List viewable at a time, you can use the same Store just filter it for whatever List is currently viewable.

    Otherwise you will need a separate Store for each List.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    2
    Vote Rating
    0
    MrBuzzy is on a distinguished road

      0  

    Default


    Thanks for the reply. I see what you mean. It still seems a bit annoying that I would have to apply the filter appropriately as each view is displayed.

    Unfortunately it's not actually working for me. The first time I call the store filter function, the records are filtered correctly. But when I call filtler again (for the second tab) the result set is reduced to nothing.

    The docs suggest it's as simple as this;

    myStore.filter("myProperty","myValue");

    Is there anything else I'm missing? And how do I 'reset' the filter to go back to the original record set?

    Thanks.

  4. #4
    Sencha User
    Join Date
    Apr 2008
    Posts
    330
    Vote Rating
    0
    Jack_S is on a distinguished road

      0  

    Question


    Running into the same problem.

    Need to apply 2 level filter to 1 combobox (filter(cid) by customer id, then filter(name) project_name.

    Thanks in advance for any assistance with this .

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You cannot share a Store and have different filters. If you have two Components and one filters the Store, the other Component WILL reflect the filter.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #6
    Sencha User
    Join Date
    Feb 2011
    Posts
    18
    Vote Rating
    0
    RyanFreng is on a distinguished road

      0  

    Default


    I have a tabpanel where each tab is a filtered version of one store. The default tab is filtered and the second tab is unfiltered. Here's the code for teh tabpanel:

    Code:
      librariesTabPanel = new Ext.TabPanel({
          height: '100%',
          listeners: {
                beforecardswitch: function(list, newlist) {
                    if (newlist.getComponent(0).getId() == librariesOpenNowList.getId()) {
                        var store = librariesOpenNowList.getStore();
                        store.filter("is_open_now", /(am|pm|hour)/);
                    } else {
                        var store = librariesAllList.getStore();
                        store.clearFilter();
                    }
                }
            },
          items: [{
            title: 'Open Now', 
            items: [librariesOpenNowList]
          },{
            title: 'All', 
            items: [librariesAllList]
          }],
        });
    The beforecardswitch listener allows me to filter when there is a card switch. Then here's my filtered and unfiltered list objects:

    Code:
      librariesOpenNowList = new Ext.List({
          store: LibraryStore,
          height: '100%',
          itemTpl: '<div class="library"><strong>{name}</strong><p>{is_open_now}</p></div>',
          grouped: true,
          indexBar: true,
          listeners: {
              beforerender: function(list) {
                  var store = list.getStore();
                  store.filter("is_open_now", /(am|pm|hour)/);
              },
              itemtap: function(list, i) {
                var rec = list.store.getAt(i),
                  id = rec.get('short_name') + '-card',
                  c = librariesPanel.getComponent(id);
    
                if(!c){
                  c = librariesPanel.add(createLibraryChild(rec, id));              
                  //librariesPanel.add(c);
                }            
                librariesPanel.setActiveItem(c, 'slide');
              }
          }
        });
    
        librariesAllList = new Ext.List({
          store: LibraryStore,
          height: '100%',
          itemTpl: '<div class="contact"><strong>{name}</strong></div>',
          grouped: true,
          indexBar: true,
          listeners: {
              beforerender: function(list) {
                  var store = list.getStore();
                  store.clearFilter();
              },
              itemtap: function(list, i) {
                var rec = list.store.getAt(i),
                  id = rec.get('short_name') + '-card',
                  c = librariesPanel.getComponent(id);
                
                  if(!c){
                    c = librariesPanel.add(createLibraryChild(rec, id));              
                    librariesPanel.add(c);
                  }
                librariesPanel.setActiveItem(c, 'slide');
              }
          }
        });

  7. #7
    Sencha User
    Join Date
    Mar 2011
    Posts
    39
    Vote Rating
    3
    Rhoover is on a distinguished road

      0  

    Default


    more newness here, and the scars on my forehead are starting to hurt .

    tackling pretty much the same issue here i think: sorting the same store differently depending on previous user behavior.

    i have a basic onReady app where everything works just fine, no errors:

    PHP Code:
    Ext.regApplication({

        
    name:'brewnotes',
        
    onReady: function() {................... 
    i have a models.js:

    PHP Code:
    //MODEL FOR TYPE
    Ext.regModel('Type',{
        
    fields:[
            {
    name:'typeName',type:'string'},
            {
    name:'typeNameTitle',type:'string'},
            {
    name:'typeCategory',type:'string'},
            {
    name:'typeStyle',type:'string'}
        ]
    }); 
    and a stores.js:

    PHP Code:
    //STORE FOR TYPES
    Ext.regStore('typeStore',{
        
    storeId:'typeStore',
        
    model:'Type',
        
    filters:['typeCategory','typeStyle'],
        
    autoLoad:true,
        
    autoDestroy:true,
        
    data:[
            {
    typeName:'paleale',typeNameTitle:'Pale Ale',typeCategory:'ale',typeStyle:'british'},
            {
    typeName:'lightale',typeNameTitle:'Light Ale',typeCategory:'ale',typeStyle:'scottish'},
            {
    typeName:'kolsch',typeNameTitle:'Kölsch',typeCategory:'ale',typeStyle:'german'},
            {
    typeName:'germanpilsener',typeNameTitle:'German Pilsener',typeCategory:'lager',typeStyle:'german'},
            {
    typeName:'bohemianpilsener',typeNameTitle:'Bohemian Pilsener',typeCategory:'lager',typeStyle:'german'},
            {
    typeName:'premiumlager',typeNameTitle:'Premium Lager',typeCategory:'lager',typeStyle:'northamerican'}
        ]
    }); 
    everything hums along nicely until i try to filter this store, in the forms panel, depending on previous selections:

    PHP Code:
    //begin brewnotes form page
    var newnote = {
         
    id:'formpanel',
         
    fullscreen:true,
         
    //url:'storage/brewnotes.json',
         
    standardSubmit:false,
         
    layout:{type:'vbox',pack:'center',align:'left',flex1},
         
    scroll:'vertical',
         
    items: [
              {
    xtype:'fieldset',title:'*Brew Name:',defaults:{required:true,labelAlign:'left',labelWidth:'33%'},
                   
    items: [
                        {
    xtype:'textfield',
                        
    name:'brewName',
                        
    placeHolder:'Type Here',
                        
    useClearIcon:true,
                        
    autoCapitalize:false}
                   ]
              },
              {
    xtype:'fieldset',title:'*Brewery Name:',defaults:{required:true,labelAlign:'left',labelWidth:'33%'},
                   
    items: [
                        {
    xtype:'textfield',
                        
    name:'breweryName',
                        
    placeHolder:'Type Here',
                        
    useClearIcon:true,
                        
    autoCapitalize:false}
                   ]
              },
              {
    xtype:'fieldset',title:'*Brew Category (tap to select):',defaults:{required:true,labelAlign:'left',labelWidth:'33%'},
                   
    items: [
                        {
    xtype:'pickerselectfield',
                        
    name:'categoryName',
                        
    valueField:'categoryName',
                        
    displayField:'categoryTitle',
                        
    store:Ext.getStore('categoryStore')}
                   ]
              },
              {
    xtype:'fieldset',title:'*Brew Style (tap to select):',defaults:{required:true,labelAlign:'left',labelWidth:'33%'},
                   
    items: [
                        {
    xtype:'pickerselectfield',
                        
    name:'styleName',
                        
    valueField:'styleName',
                        
    displayField:'styleTitle',
                        
    store:Ext.getStore('styleStore')}
                   ]
              },
    //
    //The Heart of the problem starts here
    //
              
    {xtype:'fieldset',title:'*Brew Type (tap to select):',defaults:{required:true,labelAlign:'left',labelWidth:'33%'},
                    
    items: [
                        {
    xtype:'pickerselectfield',
                        
    name:'typeName',
                        
    valueField:'typeName',
                        
    displayField:'typeNameTitle',
                        
    store:Ext.getStore('typeStore')}
                   ],
                        
    listeners:{
                        
    change: function(){
                        
    styleName this.getValue();
                        },
                        
    change: function(){
                        
    categoryName this.getValue();
                        },
                        
    beforerender:function(){
                            var 
    store='typeStore';
                            
    store.filter('styleCategory'); //ERROR GENERATED HERE
                        //store.clearFilter;
                        
    },
                        }
    //end listeners
              
    },
    ........................................ 
    which nets me the dreaded "UnCaught TypeError: Object typeStore has no method 'filter' ".

    i've researched this forum as thoroughly as possible, tried every approach presented, and have hit a brickwall.

    any insights? anything strike you as egregiously wrong-headed? please and thank you!

  8. #8
    Sencha User
    Join Date
    Nov 2010
    Posts
    73
    Vote Rating
    0
    irfaniqbal is on a distinguished road

      0  

    Default


    Quote Originally Posted by MrBuzzy View Post
    Hello, I'm pretty new to Sencha and I'm just not understanding how to do this, perhaps someone could shed some light.

    I have an auto-loading Store that contains a bunch of records. Then, I have a few tabs that each contain a list.

    I would like each list to display a 'filtered' view of the data within the store. For example, list1 displays filtered store data and list2 displays a different filtered view of the store.

    How can I add different filters for different views? Do I need to create a store for each list view?

    I looked into adding the filter to the Store config, but this filters on the entire store, not useful for creating sub-views of the original store data.

    Many thanks.
    hi MrBuzzy,
    I have a solution for this problem.

    Code:
    Application.views.myTabPanel = Ext.extend(Ext.TabPanel, {
        initComponent: function() {
            Ext.apply(this, {
                items: [item1 , item2, item3]
            });
            Application.views.myTabPanel.superclass.initComponent.apply(this, arguments);
        },
        listeners: {
            beforecardswitch: function(cmp, newCard, oldCard, index, animated){
                var cardId = newCard.getId();
                if(cardId == 'item1_Id'){
                    store.clearFilter();
                    store.filter('field', 'value');
                }else if (cardId == 'item2_Id'){
                    store.clearFilter();
                    store.filter('field', 'value');
                }else if (cardId == 'item3_Id'){
                    store.clearFilter();
                    store.filter('field', 'value');
                }
            }
        }
    });
    Also on store load set the filter of first Card. Hope this helps.

  9. #9
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    47
    Vote Rating
    1
    ruslan.talpa is on a distinguished road

      0  

    Default


    How about creating substores which get the data from that master store.
    Join this thread http://www.sencha.com/forum/showthre...-another-store to discuss this

  10. #10
    Sencha User
    Join Date
    Apr 2012
    Posts
    1
    Vote Rating
    0
    Injubert is on a distinguished road

      0  

    Default Filtering Stores

    Filtering Stores


    if you have applied a filter on a store in one list, and then in the second list you apply a filter again, you have two filters on the same store. The combined result of the two filters would most likely end up showing nothing, if your data can either be of type a or type b, and not type a and b at the same time.

    Try using clearFilter when you switch the list and then apply a filter. Then you know you have only one filter applied on the store's data.

Similar Threads

  1. Read multiple lists with Json
    By gp40 in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 28 Jan 2011, 10:29 AM
  2. Replies: 1
    Last Post: 30 Jan 2008, 6:53 PM
  3. What is the Ext form element for multiple selection lists?
    By maya in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 4 Jun 2007, 7:02 AM
  4. Filtering a single Store for Multiple Comboboxes
    By fay in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 7 May 2007, 1:09 PM

Thread Participants: 7

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi