Results 1 to 3 of 3

Thread: „item.addCls is not a function“ error when trying to replace the items of a componen

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    7

    Default „item.addCls is not a function“ error when trying to replace the items of a componen

    I’m using ExtJs6.2.0, classic toolkit.

    I have created 4 classes each one is an extension of Ext. panel.Panel.

    In my application I use an instance of each class, The instances are nested because each one is an item of a parent component, giving the following nested sequence:

    Mappanel.js -> Mapbox.js -> Mapheader.js -> Maplogo.js

    I would like to change the content of the Maplogo class so that another logo is shown. To do this I have created a derived class of Maplogo.js (let’s call it NewMaplogo.js).

    I thought that instead of deriving the whole class nesting, a simpler way to replace a Maplogo instance with a NewMaplogo instance would be to change the Mapheader items from the Mappanel controller, that is,

    1.get to the Mapheader instance through the Mapheader itemId:
    var mapheader = this.getView().down(‘#mapheader_id’)

    2.replace the Mapheader items:
    mapheader.items.items = []
    mapheader.items.items = [{instance of NewMaplogo}]

    unfortunately this solution doesn’t work because I get the following error:

    „item.addCls is not a function“

    Do you know why?
    Thank you in advance for your help

  2. #2
    Sencha User yeghikyan's Avatar
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    Use "Ext.panel.Panel.removeAll()" instead of "mapheader.items.items = []"
    Use "Ext.panel.Panel.add({instance of NewMaplogo})" instead of "mapheader.items.items = [{instance of NewMaplogo}]"
    Forget about .items property.
    "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." – Edsger W. Dijkstra

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    7

    Default

    Quote Originally Posted by yeghikyan View Post
    Use "Ext.panel.Panel.removeAll()" instead of "mapheader.items.items = []"
    Use "Ext.panel.Panel.add({instance of NewMaplogo})" instead of "mapheader.items.items = [{instance of NewMaplogo}]"
    Forget about .items property.
    Thank you so much Yeghikyan, now it works!

Similar Threads

  1. Replies: 2
    Last Post: 3 Apr 2014, 12:04 PM
  2. Replies: 1
    Last Post: 11 Apr 2013, 11:53 AM
  3. Replies: 4
    Last Post: 24 Feb 2012, 1:16 PM
  4. 1.1.0 Ext.List addCls Documentation Error
    By benwhite in forum Sencha Touch 1.x: Bugs
    Replies: 1
    Last Post: 4 Jan 2012, 12:37 PM
  5. addCls throws Cannot call method 'replace' of undefined
    By testvogel in forum Sencha Touch 2.x: Q&A
    Replies: 5
    Last Post: 13 Dec 2011, 7:53 AM

Posting Permissions

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