function OnClientItemOpening(menu, args) { var item = args.get_item(); var cols = args._item._itemData.length; for (var j = 0; j < cols; j++) { if (args._item._itemData[j].value == "FileID" || args._item._itemData[j].value == "fileSizeValue" ) { if (args._item._itemData[j].value == "fileSizeValue") { item.get_items().getItem(j).get_element().style.display = "none"; } else { item.get_items().getItem(j).get_element().disabled = true; } } } }With this code , i am able to disable/hide the coulmns of the HeaderContextMenu. But this works fine only with IE , not with Mozilla firefox.
Both the display and disabled properties are not working only in FireFox browser.
We are in urgent need of it. Kindly help us in solving this issue as early as possible.
Thanks,
Sudha.
6 Answers, 1 is accepted
Any updates on this ?
Kindly reply.
Thanks,
Sudha.
I would suggest you to use on of the built-in disable() / set_enabled(bool) methods of the RadMenuItem object, they should work in all browsers. Since the menu items are whole objects, disabling only their HTML representation may not always work, as the object itself has an enabled/disabled state.
If this does not work for you, please post the most recent version of this method, along with how and where you attach it to the header context menu of the grid.
Regards,
Tsvetina
the Telerik team
Hi,
We are not using the RadMenu. We are using the HeaderContextMenu for the RadGrid.
To get this , we have set EnableHeaderContextMenu= true in the RadGrid.
We need to disable some of the column names in the HeaderContextMenu so that user is not allowed to Hide/Unhide those columns.
The code posted in my original post is the latest.
This is the HeaderContextMenu mark up on the grid:
<
HeaderContextMenu OnClientItemOpening="OnClientItemOpening" OnClientItemClosing="OnClosing">
</HeaderContextMenu>
Please suggest how to proceed with this requirement.
Regards,
Sudha
Hi,
We are not using the RadMenu. We are using the HeaderContextMenu for the RadGrid.
To get this , we have set EnableHeaderContextMenu= true in the RadGrid.
We need to disable some of the column names in the HeaderContextMenu so that user is not allowed to Hide/Unhide those columns.
The code posted in my original post is the latest.
This is the HeaderContextMenu mark up on the grid:
<
HeaderContextMenu OnClientItemOpening="OnClientItemOpening" OnClientItemClosing="OnClosing">
</HeaderContextMenu>
Please suggest how to proceed with this requirement.
Regards,
Sudha
public static void RemoveColumnsFromContextMenu(Hashtable UniqueColNames, RadMenuItemCollection menuItems){ UniqueColNames.Add("EditColumn", ""); UniqueColNames.Add("ViewColumn", ""); UniqueColNames.Add("DeleteColumn", ""); UniqueColNames.Add("AddSaveColumn", ""); for (int iTopItemIndex = 0; iTopItemIndex < menuItems.Count; iTopItemIndex++) { if (menuItems[iTopItemIndex].Value == "ColumnsContainer") { var iNumLowerMenuItems = menuItems[iTopItemIndex].Items.Count; for (int iLowerItemIndex = iNumLowerMenuItems - 1; iLowerItemIndex >= 0; iLowerItemIndex--) { string sName = menuItems[iTopItemIndex].Items[iLowerItemIndex].Value; string sColName = sName.Split('|')[1]; if (UniqueColNames[sColName] != null) { menuItems[iTopItemIndex].Items.RemoveAt(iLowerItemIndex); } } } }}Regards,
Jos
The RadMenuItem is an object of the RadContextMenu as well, so the set_enabled() property is applicable for it too. Have you tried it to confirm there is a problem with using it?
Best wishes,
Tsvetina
the Telerik team