1. #1
    Sencha User
    Join Date
    Apr 2009
    Posts
    24
    Vote Rating
    0
    ks2009 is on a distinguished road

      0  

    Default Local array to Simple Store

    Local array to Simple Store


    Hi,

    I am trying to create a simple store out of a local array as follows:

    var arr = [];
    for(i=1;i<=20;i++)
    {
    var m = {id:i, lvl: i};
    arr.push(m);
    }

    var storeLevels = new Ext.data.SimpleStore({
    fields: [{name:'id', type: 'int'},{name:'lvl',type: 'int'}],

    });

    storeLevels.loadData(arr);

    And here is my combo box definition as follows:

    {
    xtype: 'combo',
    name: 'lvlfrom',
    fieldLabel: 'From*',
    allowBlank: false,
    triggerAction:'all',
    readOnly:true,
    mode: 'local',
    store: storeLevels,
    displayField: 'lvl',
    valueField: 'id',
    width:128
    },

    But my combo box is displaying 20 items with blank values.

    Thanks.

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    A Simple store reads each row as an Array using an Ext.data.ArrayReader.

    You have each row as an Object which would require a Store which used an Ext.data.JsonReader

  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


    As Animals says.

    If you want to use a SimpleStore:

    PHP Code:
    var arr = [];
    for(
    i=1;i<=20;i++)
    {
      var 
    = {id:ilvli};
      
    arr.push([m.idm.lvl]); 


  4. #4
    Sencha User
    Join Date
    Apr 2009
    Posts
    24
    Vote Rating
    0
    ks2009 is on a distinguished road

      0  

    Default


    Thanks a lot for your help. It works now.

  5. #5
    Sencha User
    Join Date
    Dec 2010
    Posts
    8
    Vote Rating
    0
    pradippadwal is on a distinguished road

      0  

    Default


    is it possible to convert SimpleStore to array?

Thread Participants: 3

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