1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    34
    Answers
    2
    Vote Rating
    0
    jjaskols is on a distinguished road

      0  

    Default Answered: callParent function is undefined in NestedList definition

    Answered: callParent function is undefined in NestedList definition


    Hello,

    I am trying to listen to different events in a NestedList and either swallow or propagate the event, depending on its origin. This is the code:
    Code:
      Ext.define('Switch.view.DeviceList', {       
            extend: 'Ext.Container',
            requires: [
                    'Switch.view.DeviceListItem'
            ],
            xtype: 'nesteddevicelist',
            config: {
                    layout: 'fit',
                    margin: '5 5',
                    items: [
                    {
                            title: 'Device List',
                            xtype: 'nestedlist',
                            store: 'switchstore',
                            id: 'nesteddevicelist',
                            onItemDisclosure: true,
                            detailCard: {
                                    html: 'You can see detail information here'
                            },
                            getItemTextTpl: function(node) {
                                    return  '<div class="cl_nlwrapper" style="overflow:true">' +
                                               '<div class="cl_nlcontent" style="float:left">'+
                                               '<div><b>{device_name}</b></div>' +
                                               '</div>' +
                                               '<div class="cl_switchButton" style="float:right">' +
    
    
                                               '<input type="button" name="switchButton" value="Active" ' +
                                               'style="padding:3px;">' +
                                               '</div>' +
                                               '</div>';
                            },
                            onItemTap: function(view, index, target, record, e, options) {
                                    console.log('item tapped');
                                    if (e.target.name) {
                                            if (e.target.name === 'switchButton') {
                                                    console.log('switchButton clicked');
                                                    Ext.Msg.alert('switchButton was clicked');              
                                                    e.stopPropagation();  // THIS DOES NOT WORK
                                            }
                                    }  else {
                                            console.log("list item tapped");
                                            this.callParent(arguments); // THIS IS UNDEFINED
                                    }
                            },
                            onItemDisclosure: function(list, record, target, index, e, eOpts) {
                                    console.log('disclosed');
                                    Ext.Msg.alert('switchButton was clicked');
                            }
                    }
                    ]
            }
    });
    I marked the two calls, that either do not work, or else fail with an error, because this.callParents is undefined.

    Am I instantiating/defining the list wrong, or is this in the wrong scope?

    I have been spending days on this now.

  2. getItemTextTpl and onItemTap are not listed as a config in the API docs because they are not in the config object in the NestedList class definition or a superclass.

    To do what you want to do you need to extend NestedList and use that code to override the getItemTextTpl and onItemTap methods.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,821
    Answers
    3470
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    this.callParent cannot be used in a config object when creating an instance. It should only be used when creating a class definition or an override. Also in production this will break because the methods you are using are not valid configs
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    34
    Answers
    2
    Vote Rating
    0
    jjaskols is on a distinguished road

      0  

    Default


    Could you be more specific about why the methods (functions?) are not valid configs? I stopped using the NestedList, but this seems like this is something I might be doing wrong in other areas as well.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,821
    Answers
    3470
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    getItemTextTpl and onItemTap are not listed as a config in the API docs because they are not in the config object in the NestedList class definition or a superclass.

    To do what you want to do you need to extend NestedList and use that code to override the getItemTextTpl and onItemTap methods.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    34
    Answers
    2
    Vote Rating
    0
    jjaskols is on a distinguished road

      0  

    Default


    Thank you, I will keep it in mind!