javascript - XTemplate definition on items property of a ListItem -
i'm using sencha 2.3.0 , want have xtemplate side-to-side component (textfield) on listitem. code above works fine dataview/dataitem, want use grouped property available on list/listitem.
the nested xtemplate gets rendered fine dataitem. how can make work listitem? i'm receptive solutions drop nested structure , use xtemplate tpl property directly on listitem (of course textfield listeners must implemented well).
list
ext.define( 'app.view.mylist', { //extend: 'ext.dataview.dataview', extend: 'ext.dataview.list', xtype: 'mylist', requires: [ 'app.view.myitem' ], config: { title: "mytitle", cls: 'mylist', defaulttype: 'myitem', grouped: true, store: 'mystore', usecomponents: true, itemcls: 'myitem', items: [ { // components } ] } });
listitem
ext.define( 'app.view.myitem', { //extend: 'ext.dataview.component.dataitem', extend: 'ext.dataview.component.listitem', xtype: 'myitem', config: { cls: 'myitem', items: [ { xtype: 'component', tpl: new ext.xtemplate([ '<table cellpadding="0" cellspacing="0" class="myitemxtemplate">', //some xtemplate content '</table>' ].join( "" ), { compiled: true }) }, { label: 'some label', cls : 'myitemtextfield', xtype: 'textfield', name: 'myitemtextfield' } ] } });
thanks in advance!
modifed /touch-2.4.2/examples/list/index.html
the model:
ext.define('model1', { extend: 'ext.data.model', config: { fields: [ {name: 'firstname', type: 'string'}, {name: 'lastname', type: 'string'} ] } });
the customlistitem
ext.define('dataitem', { extend: 'ext.dataview.component.listitem', xtype: 'basic-dataitem', requires: [ 'ext.button', 'ext.component', 'ext.layout.hbox', 'ext.field.checkbox' ], config: { datamap : { /* getfirstname : { setdata : 'firstname' },*/ getlastname : { setvalue : 'lastname' } }, layout: { type: 'hbox', height:'200px', }, firstname: { cls: 'firstname', xtype:'component', data:{data:'hej'}, tpl: new ext.xtemplate([ '<h1>', '{data}', '</h1>' ].join(""), { compiled: true }) }, lastname: { xtype:'textfield', css:'lastname' } }, applyfirstname : function (config) { return ext.factory(config, ext.component, this.getfirstname()); }, updatefirstname : function (newname) { if (newname) { this.add(newname); } }, applylastname : function (config) { return ext.factory(config, ext.component, this.getlastname()); }, updatelastname : function (newage) { if (newage) { this.add(newage); } }, applyfirstname: function (config) { return ext.factory(config, 'ext.component', this.getlastname()); }, updaterecord: function(record) { if (!record) { return; } this.getfirstname().setdata({data:record.get("firstname")}); this.callparent(arguments); } });
the store
var store = ext.create('ext.data.store', { //give store fields model: 'model1', //filter data using firstname field sorters: 'firstname', //autoload data server autoload: true, //setup grouping functionality group first letter of firstname field grouper: { groupfn: function (record) { return record.get('firstname')[0]; } }, //setup proxy store use ajax proxy , give url load //the local contacts.json file proxy: { type: 'ajax', url: 'contacts.json' } });
the list
xtype: 'list', usesimpleitems: false, defaulttype: 'basic-dataitem', id: 'list', ui: 'round', //bind store list store: store
Comments
Post a Comment