Welcome Guest Search | Active Topics | Sign In | Register

get menu items from NavigationItemGroup Options
K.Sz.
Posted: Friday, February 1, 2008 7:28:11 AM
Rank: Newbie
Groups: Member

Joined: 1/25/2008
Posts: 9
Hi,
my problem is that I need to get reference to MenuItem objects - contained in a NavigationItemGroup -, to use their setChecked method. I searched the ViewDoc for any appropriate method of the NavigationItemGroup object, but I found only methods which return references to NavigationItems. The following code doesn't work:
Code: JavaScript
cItem = eventInfo.getItem();
sGroup = cItem.getSubGroup();
for (i = 0; i < sGroup.getItemCount(); i = i + 1)
        {
            elemszam = elemszam + 1;
            elem = sGroup.getItemByIndex(i);  
            elem.setChecked(true);  //elem doesn't have this method
        }

I suppose this is quite easy, so could you please give me a clue?
eo_support
Posted: Friday, February 1, 2008 7:35:56 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

setChecked is only available on MenuItem object. So if the control you are working on is a menu, setChecked should work. Otherwise you would need to use other methods. For example, you would need to use setCheckState for a TreeView. setCheckState is available on TreeNode object.

Thanks
K.Sz.
Posted: Friday, February 1, 2008 7:51:32 AM
Rank: Newbie
Groups: Member

Joined: 1/25/2008
Posts: 9
Thanks for your quick reply.
However, the control is a SlideMenu, and the code which I sent is part of the "ClientSideOnItemClick" eventhandler.
<eo:SlideMenu ClientSideOnItemClick="cbClick" ...>
My aim is that if we click on a top-level menu item, then all SubMenu items should be set to Checked as well. The following code works:

Code: JavaScript
cItem.setChecked(!cItem.getChecked());


However, if I want to iterate through the SubGroup collection of the clicked item, I am not able to access the Checked properties.

Code: JavaScript
function cbClick(e, eventInfo)
{
...
cItem = eventInfo.getItem();
sGroup = cItem.getSubGroup();
cItem.setChecked(!cItem.getChecked());

for (i = 0; i < sGroup.getItemCount(); i = i + 1)
        {
            elemszam = elemszam + 1;
            elem = sGroup.getItemByIndex(i);  
            elem.setChecked(true);    //the problematic line
        }
...
}


Thanks
eo_support
Posted: Friday, February 1, 2008 8:56:47 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I tried your code with the latest version and your code works fine. Can you try a blank page with a single slide menu?

Thanks
K.Sz.
Posted: Sunday, February 3, 2008 11:54:29 PM
Rank: Newbie
Groups: Member

Joined: 1/25/2008
Posts: 9
I tried the code with a simple slide menu, without data binding, and it really works fine. However, I need to fetch the menu items from a datatable, and if I do so, I get to the same problem. Internet Explorer shows me the following error description (this is just a translation):
"The value of this.aro.parentNode is NULL, or is not an object"
After this, only the first SubMenu item is checked, and it loses its Text.
K.Sz.
Posted: Monday, February 4, 2008 12:24:29 AM
Rank: Newbie
Groups: Member

Joined: 1/25/2008
Posts: 9
I also tried to use checkboxes, but I couldn't find any methods in the Client API reference, which gives me a reference to a template-generated item (similar to the server-side FindControl method).
eo_support
Posted: Monday, February 4, 2008 6:42:00 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
K.Sz. wrote:
I tried the code with a simple slide menu, without data binding, and it really works fine. However, I need to fetch the menu items from a datatable, and if I do so, I get to the same problem. Internet Explorer shows me the following error description (this is just a translation):
"The value of this.aro.parentNode is NULL, or is not an object"
After this, only the first SubMenu item is checked, and it loses its Text.


Hi,

We are not sure how data binding can make a difference. Because regardless how the slide menu is generated on the server side, they are all the same when it comes to the client side, in fact, you can view a static slide menu as dynamically generated from your .aspx file. So whatever way it is generated from, it should all behave the same way on the client side. Thus in order to further look into the problem, we would need to you create a sample for us that demonstrates the problem, as soon as we can see the problem, it should be easy to fix/workaround.

Checkbox based on ItemTemplate is much more difficult to use. It will be much easier to get setChecked working.

Thanks
K.Sz.
Posted: Wednesday, February 6, 2008 12:22:55 AM
Rank: Newbie
Groups: Member

Joined: 1/25/2008
Posts: 9
Hi,

I discovered that my problem was that I used templates to generate checkboxes, and hidden fields to provide some additional functionality (however, these can also be solved by using the built-in funcionality). After I removed the templates the code worked properly.
Thanks for your help!

K.Sz.
Posted: Wednesday, February 6, 2008 3:10:55 AM
Rank: Newbie
Groups: Member

Joined: 1/25/2008
Posts: 9
Hi,

Now the Javascript part of the job works fine, but when inspecting the Checked properties of the MenuItems with a server-side code, the Checked prop is always false.
Here's the JavaScript code, I suppose this is good - the right items are thicked; when I randomly check some items with getChecked, the return value is good -:
Code: JavaScript
function cbClick(e, eventInfo)
{
    cItem = eventInfo.getItem();
    all = !cItem.getChecked();
    kibont(cItem, all);
}

function kibont(cItemKibont, all)
{
    if (cItemKibont.getSubGroup())
    {
        var sGroup = cItemKibont.getSubGroup();
        if ((sGroup.isVisible()) || (sGroup.getLevel()>1))
        {
            
            cItemKibont.setChecked(all);
            var i;
            for (i = 0; i < sGroup.getItemCount(); i = i + 1)
            {
                elem = sGroup.getItemByIndex(i);
                elem.setChecked(all);
                if (elem.getSubGroup()) 
                {
                    kibont(elem, all); 
                }
           }
        }
    }
    else
    {
        cItemKibont.setChecked(!cItemKibont.getChecked());
    }
    
    return 1;
}


And when I use server-side code at the eventhandler of a button the return value is alway false:

Code: Visual Basic.NET
...
If SlideMenu4.Items(i).Checked Then
...


Thanks
eo_support
Posted: Wednesday, February 6, 2008 5:22:17 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Currently the changes made on the client side are not passed back to the server for menu or slide menu. It is only supported on the TreeView. We will look into it to see if we can add them on the menu and slide menu.

Thanks
K.Sz.
Posted: Wednesday, February 6, 2008 8:13:50 AM
Rank: Newbie
Groups: Member

Joined: 1/25/2008
Posts: 9
Ok, now I modified the code, so I pass the IDs of the selected items in a hiddenfield. This way it works great.

Thanks.
eo_support
Posted: Wednesday, February 6, 2008 8:16:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Awesome. That's definitely a good workaround.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.