1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    14
    Vote Rating
    0
    joesinla is on a distinguished road

      0  

    Default Custom DataView store

    Custom DataView store


    I'd like a DataView to have 4 of the latest created items in a store. I'd like no other components that use the same store to be sorted or affected. I can of course select a store from the config options, but that will display all of the records.

    How can I load only 4 records into a dataview?

    I have tried to load a new sorted store into the dataview when the store load event fires, that didn't work...

  2. #2
    Touch Premium Member BostonMerlin's Avatar
    Join Date
    Aug 2010
    Location
    Boston
    Posts
    515
    Vote Rating
    41
    BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about

      1  

    Default


    If you have multiple views sharing the same store, and you filter or sort that store, all views are effected. You must create a separate store for any view that needs a subset of a specific store.

    There are several ways to handle this... one way is to create a copy of the primary store (all records) then just filter the copy. In one of my projects I had a store with quite a bit of data in it. Several views needed to see this data slightly differently and they were all displayed on the screen at the same time as Widgets. What I did was create a function that I could call that would return a custom store copy based on params I passed into it. The function made a new store based on my primary store, filtered and sorted the store copy then returned it. I then assigned that store copy to as many views as necessary.

    Hope that helps
    John
    I love being a dad (5 & 7), flying airplanes (KBED) and writing code (spaghetti).
    BostonMerlin aka John Bond aka JB
    See U @ SenchaCon '13

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    14
    Vote Rating
    0
    joesinla is on a distinguished road

      0  

    Default


    That sure did help, and helped me better understand how to deal with various views and stores. Thanks a bunch!

    I did this:
    Code:
    var records = [];
    
    if(store.getData().length !== 0){
        
        store.sort('Created', 'DSC');
        
    	for(var i = 0; i<4; i++){
    		records.push(store.getData().items[i]);
    	}
    }
    
    
    var store2 = Ext.create('Ext.data.Store');
    
    
    store2.add(records);
    
    
    var hdv = this.getHomeDataView();
    
    
    if(hdv){
        hdv.setStore(store2);
    }

  4. #4
    Touch Premium Member BostonMerlin's Avatar
    Join Date
    Aug 2010
    Location
    Boston
    Posts
    515
    Vote Rating
    41
    BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about

      0  

    Default


    Great! Make sure to mark as answered.

    John.
    I love being a dad (5 & 7), flying airplanes (KBED) and writing code (spaghetti).
    BostonMerlin aka John Bond aka JB
    See U @ SenchaCon '13

Thread Participants: 1

Tags for this Thread

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