1. #1
    Sencha User
    Join Date
    May 2013
    Posts
    22
    Vote Rating
    0
    Answers
    1
    saklak is on a distinguished road

      0  

    Default Answered: Two lists same store

    Answered: Two lists same store


    Hi,

    I got this class where I'm trying to show some data from the same store in the same container. I did it this way because I want to have two rows each on a separate line and I was not having too much control over them. Here's the class:

    Code:
    Ext.define('Clue.view.ListQuestions', {
        extend: 'Ext.Container',
        requires: ['Ext.dataview.List'],
        xtype: 'listquestions',
    
    
    
    
        config: {
            id: 'listquestions',
            items: [{
                 xtype: 'list',
                 id: 'questionLi1',
                 baseCls: 'questionLi1',
                 flex: 1,
                 store: {
                     xtype: 'levelstore',
                     filters: [{
                         filterFn: function(item) {
                             return item.data.levelId < 2 && item.data.questionId < 6;
                         }
                     }]
                 },
                 itemTpl: '<div>{questionId}</div>'
             },{
                xtype: 'list',
                id: 'questionLi2',
                baseCls: 'questionLi2',
    
    
                flex: 1,
                store: {
                    xtype: 'levelstore',
                    filters: [{
                        filterFn: function(item) {
                            return item.data.levelId < 2 && item.data.questionId > 5;
                        }
                    }]
                },
                itemTpl: '<div>{questionId}</div>'
            }]
        }
         })
    If I remove the second list, first list is showing, otherwise the first list is not showing.
    here's the store:

    Code:
    Ext.define('Clue.store.LQuestions', {
        extend: 'Ext.data.Store',
        xtype: 'levelstore',
        requires: ['Ext.data.proxy.LocalStorage'],
    
    
        config: {
            model: 'Clue.model.LQuestions',
            storeId: 'levelStore',
            sorters: [{
                property: 'levelId',
                direction: 'ASC'
            }],
            proxy: {
                type: 'localstorage',
                id:   'levelstorage'
            }
        }
        })
    this is what I get:
    dARrg.png

    and if I do this on the second list:

    Code:
    ... 
        flex: 1,
         /*store: {
              xtype: 'levelstore',
              filters: [{
                  filterFn: function(item) {
                       return item.data.levelId < 2 && item.data.questionId > 5;
                  }
              }]
                },*/
         itemTpl: '<div>{questionId}</div>'
        ...
    I get:

    DcnrI.png

    In the first case it seams that there is nothing in html eighter and if I put a console.log() in the first list filter function it
    does not seam to enter in that function. What am I doing wrong ?

  2. xtype is not a valid config for the store config.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    Answers
    3575
    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


    xtype is not a valid config for the store config.
    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.

  4. #3
    Sencha User
    Join Date
    May 2013
    Posts
    22
    Vote Rating
    0
    Answers
    1
    saklak is on a distinguished road

      0  

    Default


    Thanks alot. I knew that I was doing something wrong but no one was saying what
    fixed this by calling with the storeId... now I can continue my learning.

  5. #4
    Sencha User
    Join Date
    Nov 2013
    Posts
    49
    Vote Rating
    1
    Answers
    1
    anilvardhan.p is on a distinguished road

      0  

    Default hi saklak,

    hi saklak,


    i seen your example. I need a littile code help.
    I am creating a carousel, where i need to show 4 items in a page total 12 items. For this i choosed list, to get data from store.

    How i can generate 4 items with one list another 4 items as another list?

    sample pic,
    carousel.jpg

    help me out.... share some code snippet if possible.

    Thank U so much.

  6. #5
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    508
    Vote Rating
    74
    Answers
    25
    shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough

      0  

    Default


    Using different stores is currently the only way you could have the same data filtered/sorted differently in multiple lists.
    I blog about Sencha Touch at www.senchatouchdev.com