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

[Solved] Enable/Disable Context Menu items

6 Answers 418 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Srinivas
Top achievements
Rank 1
Srinivas asked on 19 Aug 2009, 12:32 AM
Hi,

I am using Context Menu for the RadGridView control and I would like to Enable/Disable some of the Context Menu items based on the data of the selected row. Please consider below example:

Row 1:
    Col1 value: 'A'
    Col2 value: 'AAA'
Row 2:
    Col1 value: 'B'
    Col2 value: 'BBB'

Context Menu for both rows
    1. Work with A
    2. Work with B

When I open the context menu on Row 1 when I would like to disable 2nd context menu item which is "Work with B" and if I open context menu on Row 2 then I would like to disable 1st context menu item which is "Work with A".

Any help is appreciated.

Thanks
Srinivas

6 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 21 Aug 2009, 07:39 AM
Hello Srinivas,

The First Look example of RadContextMenu demonstrates how to implement the requested functionality:
http://demos.telerik.com/silverlight/#ContextMenu/FirstLook

Sincerely yours,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Srinivas
Top achievements
Rank 1
answered on 22 Aug 2009, 06:03 AM
Hello Valeri Hristov,

The FirstLook example is using the TreeView Item and I tried to apply similar logic to RadGridView but could not succeeded. Do you have any sample on RadGridView? 

Also, I am using Hierarchy Property for in my grid and I would like to enable the Context Menu only on the child grid (or child record) and not on the header grid view. If it is possible, can you please give me a sample?

I really appreciate your help on this.

Thanks
Srinivas
0
Valeri Hristov
Telerik team
answered on 24 Aug 2009, 02:08 PM
Hi Srinivas,

Please, find attached a simple example, demonstrating how to customize RadContextMenu depending on the clicked RadGridView element in hierarchy mode.

Best wishes,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Srinivas
Top achievements
Rank 1
answered on 24 Aug 2009, 11:24 PM
Hi,

I am unable to compile the project as I am getting the following errors on DataItem.

I am using "RadControls for Silverlight 3 RTW" and I have included references for the following DLLs in the Visual Studio, as these references became invalid after unzip the project:

Telerik.Windows.Controls
Telerik.Windows.Controls.GridView
Telerik.Windows.Controls.Input
Telerik.Windows.Controls.Navigation
Telerik.Windows.Data

compile errors:
Error 1 'Telerik.Windows.Controls.GridView.GridViewRow' does not contain a definition for 'DataItem' and no extension method 'DataItem' accepting a first argument of type 'Telerik.Windows.Controls.GridView.GridViewRow' could be found (are you missing a using directive or an assembly reference?) C:\My Documents\Visual Studio 2008\Telerik\GridView\ContextMenuOnGridView\MainPage.xaml.cs 108 68 ContextMenuOnGridView

Can you please let me know what DLLs I am missing?

Also, it looks like the ContextMenu cannot be placed inside RadGridView.HierarchyChildTemplate , as we would like to enable or have this Context Menu only for the child records of the Grid and not for the parent records.

Thanks
Srinivas

0
Valeri Hristov
Telerik team
answered on 25 Aug 2009, 08:06 AM
Hello Srinivas,

Could you please, check the version of the assemblies you are using - it should be 2009.2.812.1030. I suppose that you are using an older version, which does not include the DataItem property.

Regarding the placing a RadContextMenu in HierarchyChildTemplate - it should be possible, but I wouldn't recommend it, because in each instance of the template, e.g. in each row, a new RadContextMenu will be created, which, if you have lots of rows, could become a problem. In the sample application, I've sent  you could detect if the context menu is opening for a parent record and close it, which will be virtually the same as if you declare a new RadContextMenu for each child record. I could send an example for RadContextMenu in HierarchyChildTemplate if you insist.

Regards,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Srinivas
Top achievements
Rank 1
answered on 29 Aug 2009, 05:37 AM
Hello Valeri Hristov,

Thank you very much for your suggestion. Yes, now I am able to disable/enable items in the context menu.

Also, as you suggesed I am not using context menu in the HierarchyChildTemplate and I do understand why you suggested this.

Thank you very much.

Srinivas
Tags
GridView
Asked by
Srinivas
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Srinivas
Top achievements
Rank 1
Share this question
or