Threaded View

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    4
    Vote Rating
    0
    Noodlese is on a distinguished road

      0  

    Default 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!

  2. 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'
                })
            });
    
        }
    });

Thread Participants: 1