This is a migrated thread and some comments may be shown as answers.

Not able to disable the items of the headerContextMenu.

6 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sudha
Top achievements
Rank 1
Sudha asked on 21 Nov 2011, 03:08 PM
Hi ,
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

Sort by
0
Sudha
Top achievements
Rank 1
answered on 22 Nov 2011, 02:11 PM
Hi team,
Any updates on this ?
Kindly reply.

Thanks,
Sudha.
0
Tsvetina
Telerik team
answered on 22 Nov 2011, 04:40 PM
Hello 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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Sudha
Top achievements
Rank 1
answered on 23 Nov 2011, 06:52 AM

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
0
Sudha
Top achievements
Rank 1
answered on 23 Nov 2011, 06:52 AM

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
0
RvdGrint
Top achievements
Rank 1
answered on 23 Nov 2011, 08:48 AM
On the PreRender event of the RadGrid I'm calling a function, RemoveColumnsFromContextMenu, to remove items from the HeaderContextMenu. In such a function you also can hide or disable some options form the HeaderContextMenu.
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
0
Tsvetina
Telerik team
answered on 23 Nov 2011, 01:57 PM
Hello Sudha,

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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Sudha
Top achievements
Rank 1
Answers by
Sudha
Top achievements
Rank 1
Tsvetina
Telerik team
RvdGrint
Top achievements
Rank 1
Share this question
or