getting index value 0 from dataview any list itemtap from sencha touch -
i unable index value form dataview:
{ xtype: 'list', itemid: 'catlist', store: 'categorystore', scrollable: false, layout: 'fit', itemheight: 20, itemtpl: [ '<div>', '<tpl for="data">', '<span >{category_name}</span> ', '</tpl>', '</div>'], listeners: { 'itemtap': function(list, index, target, record, e, eopts){ console.log(record.get('cat_id')); } } }
edited: if put data static on store works fine not work while getting data server:
it works displayed on list:
{ xtype: 'list', itemid: 'catlist', scrollable: false, data: [ { category_name: 'a', cat_id: 1}, { category_name: 'b', cat_id: 2}, { category_name: 'c', cat_id: 3}, { category_name: 'd', cat_id: 4}, { category_name: 'e', cat_id: 5}, ], loadingtext: "loading words...", emptytext: '<div>{message}</div>', autoload:true, itemtpl:[ '<tpl for=".">', '<span >{category_name}</span> ', '</tpl>', ] },
here, tap many times on different row gets index 0, why this? why not getting different index value while tapping different row of list item;
i tried , working me, let me share did.
model
ext.define('myapp.model.category', { extend: 'ext.data.model', config: { fields: [ { name: 'cat_id', type: 'integer' }, { name: 'category_name', type: 'string' }, { name: 'created_date', type: 'string' }, { name: 'order', type: 'integer' }, { name: 'status', type: 'integer' }, { name: 'deleted', type: 'integer' }, { name: 'type', type: 'integer' } ] } });
store
ext.define('myapp.store.category', { extend: 'ext.data.store', requires: [ 'myapp.model.category' ], config: { storeid: 'category', model: "myapp.model.category", proxy: { type: "ajax", url : "http://alucio.com.np/trunk/dev/sillydic/admin/api/word/categories/sdsillytoken/650773253e7f157a93c53d47a866204dedc7c363?_dc=1376475408437&page=1&start=0&limit=25", reader: { type: "json", rootproperty: "data" } }, autoload: true } });
list
{ xtype: 'list', itemid: 'catlist', store: ext.create('myapp.store.category'), layout: 'fit', itemheight: 20, itemtpl: [ '<div>', '{category_name}', '</div>'], listeners: { itemtap: function(list, index, target, record, e, eopts){ console.log(record.get('cat_id')); } } }
output
as can see itemtap function printing correct cat_id
update
based on comment
{ xtype :'panel', items : [{ xtype : 'toolbar', itemid: 'categoryname' // give itemid }, { xtype: 'list', itemid: 'catlist', height : '100%', store: ext.create('goodnews.store.category'), layout: 'fit', itemheight: 20, itemtpl: [ '<div>', '{category_name}', '</div>'], listeners: { itemtap: function(list, index, target, record, e, eopts){ var catid = record.get('cat_id'); var categoryname = record.get('category_name'); // set title this.getparent().getcomponent('categoryname').settitle(categoryname); } } }] }
Comments
Post a Comment