Results 1 to 8 of 8

Thread: Ext.menu.Menu.items.get(i) not working in IE

  1. #1
    Ext User nidkil's Avatar
    Join Date
    Sep 2008
    Posts
    30
    Vote Rating
    0
      0  

    Default Ext.menu.Menu.items.get(i) not working in IE

    Hi,

    I am using the following code to iterate through checked menu items to turn columns in a grid on and off. It works perfectly in IE, but it does not work in IE (problem line marked with <---------). Any ideas what the problem is?

    var zoomMenu = new Ext.menu.Menu({
    id:'zoomMenu',
    width:150,
    items: [
    {id:'2007', text:'2007', checked:false, checkHandler: onItemCheck, scope:this},
    {id:'2008', text:'2008', checked:true, checkHandler: onItemCheck, scope:this},
    {id:'2009', text:'2009', checked:false, checkHandler: onItemCheck, scope:this},
    "-",
    {id:'jaren', text:'Alleen jaarkolommen', checked:false, checkHandler: onItemCheck, scope:this}
    ]
    });

    function setZoomMenuText() {
    var btnText = "Zoom: ";
    var items = zoomMenu.items;
    var cnt = items.getCount();
    for(var i = 0; i < items.length; i++){
    item = items.get(i); // <---------
    if(!Ext.isIE) console.log("i=" + i + ", item=" + item);
    if(item.checked == true) btnText += " " + item.text;
    showHideColumns(item.text, (item.checked ? false : true));
    }
    return btnText;
    };

    Regards, nidkil

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,626
    Vote Rating
    56
      0  

    Default

    When you say it's not working, how do you know that that line of code is being executed?

    What is "items.length" when you STEP THROUGH YOUR CODE IN A DEBUGGER hm?
    Longtime Sencha geek. Outspoken advocate of pure Javascript Views. Posts my own opinions.

  3. #3
    Ext User nidkil's Avatar
    Join Date
    Sep 2008
    Posts
    30
    Vote Rating
    0
      0  

    Default

    Impress reaction time!

    IE gives an error message and asks if I want to debug the code. The error is caused by the line I marked. It says that the object does not support the get method. The same code works fine in Firefox.

    Ps. the length = 0 !?!?!? but cnt = 5

  4. #4
    Ext User nidkil's Avatar
    Join Date
    Sep 2008
    Posts
    30
    Vote Rating
    0
      0  

    Default

    Hi animal,

    I changed the code to this, and even though len does get the value 5 it still fails when using itemAt to get the menu item ... Any ideas?

    function setZoomMenuText() {
    var btnText = "Zoom: ";
    for(var i = 0, len = zoomMenu.items.length; i < len; i++){
    item = zoomMenu.items.itemAt(i);
    if(!Ext.isIE) console.log("i=" + i + ", item=" + item);
    if(item.checked == true) btnText += " " + item.text;
    showHideColumns(item.text, (item.checked ? false : true));
    }
    return btnText;
    };

  5. #5
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    123
      0  

    Default

    Why would you assume that items.length returns anything?

    items is a MixedCollection, which doesn't have a length property.

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,626
    Vote Rating
    56
      0  

    Default

    WHy are you using IE??????????

    If you are a developer with need to debug your code (because we all write buggy code!), then you should develop using Firefox and Firebug.
    Longtime Sencha geek. Outspoken advocate of pure Javascript Views. Posts my own opinions.

  7. #7
    Ext User nidkil's Avatar
    Join Date
    Sep 2008
    Posts
    30
    Vote Rating
    0
      0  

    Default

    Hi animal,

    I just reread my first mail and see I did not describe my problem correctly: the code DOES work in Firefox, but does NOT work in IE. Hope this info helps to find the problem.

    Regards, nidkil

  8. #8
    Ext User nidkil's Avatar
    Join Date
    Sep 2008
    Posts
    30
    Vote Rating
    0
      0  

    Default

    Hi guys,

    After browsing the forum I decided to change my code to use each and this did the trick. For anyone interested, this is the new code:

    function setZoomMenuText() {
    var btnText = "Zoom: ";

    zoomMenu.items.each(function(item){
    if(item.checked == true) btnText += " " + item.text;
    showHideColumns(item.text, (item.checked ? false : true));
    });

    return btnText;
    };

    Regards, nidkil

Posting Permissions

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