Threaded View
-
24 Jan 2013 9:25 AM #1
Answered: Using DataItem without DataView
Answered: Using DataItem without DataView
I am trying to create a component that builds itself as mapped to a record. I was taking a look at the DataItem component, but it seems like it is coupled to be used with the DataView component. I do not need the functionality of applying a "list" of DataItems to the DataView. I simply just need one DataItem to be mapped to one record.
Is there any way of using DataItem without using DataView? Or do I need to use the both of them while simply feeding the store a single record instead of an array of records.
Thanks!
-
Best Answer Posted by mitchellsimoens
Here is an example:
Code:Ext.define('MyContainer', { extend : 'Ext.Container', xtype : 'mycontainer', config : { record : null, items : true }, applyItems : function(items, collection) { var record = this.getRecord(); items = [ { flex : 1, html : record.get('left') }, { flex : 1, html : record.get('right') } ]; return this.callParent([items, collection]); } }); Ext.define('MyModel', { extend : 'Ext.data.Model', config : { fields : ['left', 'right'] } }); Ext.application({ name : 'Test', launch : function () { Ext.Viewport.setActiveItem({ xtype : 'mycontainer', layout : { type : 'hbox', align : 'stretch' }, record : new MyModel({ left : 'foo', right : 'bar' }) }); } });


Reply With Quote