0
votes

I am trying to get store value like this:

 itemtap : function(list, index, target, record) {

      Ext.getStore("nameStore").load();
      console.dir("TEST->"+record.get('id'));
      console.dir("TEST->"+record.get('address'));

}

Here I cannot get id, when itemtap. and I also try this:

  var store= Ext.getStore('nameStore');
  console.dir("TEST->"+store.get('id'));
  console.dir("TEST->"+store.get('address'));

But could not get data. Why this?

and What is the difference between this, two type of store value access?

I add onclick inside the div, itemtap working fine but in Iphone it is not working? why this? Is there any alternative is present in sencha working both android Iphone and others.How to get value in itemptap, from displayed in div which is display from store.

Edited:

 itemtap :function(list, index, target, record) {
console.log("Clicked---"+record.get('cat_id'));
}

Actually, I am not getting above code.

I am try this, and getting value

console.log("Clicked--"+record.data.data[index].cat_id);

Getting first value always, because index value always 0, every category tapped. So, Here I want get index of tapped category.

Works Fine, If i do this:

{    
          xtype: 'list', 
          itemId: 'catList',
          scrollable: false,

    data: [
    { name: 'A', cat_id: 1},
    { name: 'B', cat_id: 2},
    { name: 'C', cat_id: 3},
    { name: 'D', cat_id: 4},
    { name: 'E', cat_id: 5},


    ],
    loadingText: "Loading Words...",
    emptyText: '<div>{message}</div>',
    autoLoad:true,
    itemTpl:[
    '<tpl for=".">',
          '<span >{name}</span> ',             
      '</tpl>',
    ] 
  },
1

1 Answers

1
votes

Why are you 'reloading' the store on the itemTap callback? It should be already loaded and not necessary to load() again.

Even if you want to update the store, you should wait for load() to finish before doing record.get(). Remember load() is async.

The second block will never work because get() is a method for record, you re executing it to the store.

itemtap : function(list, index, target, record) {
      console.dir("TEST->" + record.get('id'));
      console.dir("TEST->" + record.get('address'));
}