Results 1 to 3 of 3

Thread: ComponentView with various Item Types?

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    5
    Vote Rating
    0
      0  

    Default ComponentView with various Item Types?

    Hello All-

    I'm working on a list (using ComponentList, actually, but let's set that aside) and I want to use several types of custom components for Items, depending on a Type declared in the data.

    One might be "text with an icon" while another might be a structured bar with icons and text. These might extend DataItem or the might each be a child of a common DataItem component that instantiates them based on data.

    Ideas?

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    You can override the getDataItemConfig method within the ComponentView. By default it is:

    Code:
        getDataItemConfig: function(xtype, record, itemConfig) {
            return {
                xtype: xtype,
                record: record,
                defaults: itemConfig
            };
        }
    The xtype will be the value in the defaultType config but you can return whatever you want really.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    5
    Vote Rating
    0
      0  

    Default Thanks for the quick reply!

    That is exactly what I was looking for!

    I modded it like this:

    Code:
    getDataItemConfig: function(xtype, record, itemConfig) {    	
        	if(record.data.itemType) {
        		xtype = record.data.itemType;
        	}    	
            return {
                xtype: xtype,
                record: record,
                defaults: itemConfig
            };
        }
    Now to write some more DataItem extensions that support group headers. Got one already that works!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •