1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    10
    Vote Rating
    0
    b0rn is on a distinguished road

      0  

    Default text of selected item on cyclebutton isn't shown

    text of selected item on cyclebutton isn't shown


    Hello,

    i've searched on this site (and the docs) but i couldn't solve my problem...

    I want to check if the menu of a splitbutton contains a item. If not it should be added.

    In the end the item should be selected.

    Here my code:
    Code:
    		else if (component.xtype == 'cycle')
    		{	
    			var menuItem = {text: val, group: 'land', xtype: 'menucheckitem'};
    
    			if (component.menu.items.findIndex('text', menuItem.text) < 0)
    			{
    				component.menu.add(menuItem);
    			}
    			
    		}
    So the item is available and i can select it in the GUI.

    But when it is selected the text of the previous-selected item is shown.
    Also i want to set it selected (via code).
    How can i solve this?

    Thanks in advance

  2. #2
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,341
    Vote Rating
    249
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    Best place to find the answers to questions like this is the ExtJS source code.

    From doing a bit of digging it seems that there are some properties set on the menu items when the button is first created and it doesn't make any attempt to cope with adding new items. You can add those properties yourself with something like this:

    Code:
    if (component.menu.items.findIndex('text', val) === -1) {
        var item = component.menu.add({
            checkHandler: component.checkHandler,
            group: 'land',
            itemIndex: component.itemCount++,
            scope: component,
            text: val,
            xtype: 'menucheckitem'
        });
    
        component.setActiveItem(item);
    }

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    10
    Vote Rating
    0
    b0rn is on a distinguished road

      0  

    Default


    Thank you - that works fine

    Here my code:

    Code:
    else if (component.xtype == 'cycle')
    {	
    	var item;
    	var idx = component.menu.items.findIndex('text', val)
    			
    	if (idx === -1) {
        		item = component.menu.add({
            		checkHandler: component.checkHandler,
            		group: 'land',
            		itemIndex: component.itemCount++,
            		scope: component,
            		text: val,
            		xtype: 'menucheckitem'
        		});
    	}
        	else if (idx >= 0)
        	{
        		item = component.menu.items.items[idx];
        	}
    			
    	component.setActiveItem(item)
    }

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar