1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    8
    Vote Rating
    0
    Jaya123 is on a distinguished road

      0  

    Default Unanswered: New to Sencha and having a hard time with DataItem with custom container

    Unanswered: New to Sencha and having a hard time with DataItem with custom container


    I'm trying to follow this thread http://www.sencha.com/forum/showthread.php?196320
    a
    nd created my own container for the component in the DataItem definition. I have declared
    useComponents: true, defaultType: 'mylistitem' in my DataView

    Ext.define('AgileApp.view.MyListItem', {

    extend: 'Ext.dataview.component.DataItem',
    requires: ['Ext.Button', 'AgileApp.view.SponsorList','Ext.Img',
    'AgileApp.model.Sponsors',
    'AgileApp.model.Sponsor'],
    xtype: 'mylistitem',


    config: {

    level:true,
    sponsor: true,

    dataMap: {

    getLevel: {
    setText: 'level'
    },
    getSponsor: {
    setSponsor: 'sponsor'
    }
    },

    layout: {
    type: 'vbox',
    align: 'center'
    },

    sponsor: {
    xtype:'sponsorView',
    }
    },

    applyLevel: function(config) {
    // alert(this.getLevel());
    return Ext.factory(config, Ext.Button, this.getLevel());
    },


    applySponsor: function(config) {
    // alert(this.getSponsor());
    return Ext.factory(config, AgileApp.view.SponsorList, this.getSponsor());
    },

    updateLevel: function(newNameButton, oldNameButton) {
    if (oldNameButton) {
    this.remove(oldNameButton);
    }


    if (newNameButton) {
    this.add(newNameButton);
    }
    },

    updateSponsor: function(newNameButton, oldNameButton) {
    var sponsor = Ext.getStore('Sponsor');
    if (oldNameButton) {
    sponsor.remove(oldNameButton);
    }


    if (newNameButton) {
    sponsor.add(newNameButton);
    }
    },
    });

    My component definition is like this:

    Ext.define('AgileApp.view.SponsorList', {


    extend: 'Ext.Container',


    xtype: 'sponsorView',


    config: {


    items: [
    {
    xtype: 'Sponsor_m', id:'sponsor'
    }
    ],


    html:'test',
    // itemTpl: [
    // '<tpl for=".">test{name}-------{description}</tpl>'
    // ]
    },

    setSponsor:function(store){
    alert("got into store" + store);
    }
    });

    But this is not displaying the sponsor list as expected and instead I get an error on the console:
    Uncaught TypeError: Object [object Object] has no method 'getItemId'


    i'm not able to understand what i'm doing wrong here. Any help on how to reference this custom component and display the data on that would be highly appreciated.

    Thanks

  2. #2
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    Your post really hard to read.
    Code:
    updateSponsor: function(newNameButton, oldNameButton) {
        var sponsor = Ext.getStore('Sponsor');
        if (oldNameButton) {
            sponsor.remove(oldNameButton);
        }
    
    
        if (newNameButton) {
            sponsor.add(newNameButton);
        }
    }
    sponsor is a store,oldNameButton and newNameButton are component.
    store.remove(component)?

    also remove the id config,your have many 'sponsorView' instance .
    Code:
    {
    xtype: 'Sponsor_m'
    //, id:'sponsor'
    }
    I write English by translator.

Thread Participants: 1

Tags for this Thread