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

Problem while attaching the contextmenu dynamically to GridView row.

5 Answers 72 Views
GridView
This is a migrated thread and some comments may be shown as answers.
SivaPrasad Bevara
Top achievements
Rank 1
SivaPrasad Bevara asked on 02 May 2011, 03:24 PM
Hi,

I have a gridview and Ioding it with RadDomainDataSource. 
In this I need to attach 2 RadContextMenu's based on the record statsus (success/Failure).
I am doing this in the RowLoaded event of the Gridview.

Following is the code:

if(e.Row.Item != null)
{
    if (((TransactionsDTO)e.Row.Item).PostingResult == "Success")
    {
        RadContextMenu.SetContextMenu(e.Row, RadGridViewSuccessContextMenu);

    }
    else  
    {
        RadContextMenu.SetContextMenu(e.Row, RadGridViewFailedContextMenu);
        e.Row.Background = new SolidColorBrush(Colors.Red);
    }
}  

 

 

It is properly attaching the ContextMenu in the first page. I am facing the following problem when I move to the next page.

 at Telerik.Windows.Controls.RadContextMenu.ClearReferences()
   at Telerik.Windows.Controls.RadContextMenu.OnContextMenuChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Telerik.Windows.Controls.RadContextMenu.SetContextMenu(FrameworkElement element, RadContextMenu value)
   at MyApp.Views.Transactions.customerGridView_RowLoaded(Object sender, RowLoadedEventArgs e)

This code properly worked with the previous version of Telerik (2010.3.1326.1040).
I think this was introduced in the latest version (2011.1.427.1040).

Please help.

Regards,
SivaPrasad.B

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 03 May 2011, 07:42 AM
Hello,

 Can you post more info about the error? Is it null reference exception? 

Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
SivaPrasad Bevara
Top achievements
Rank 1
answered on 05 May 2011, 06:48 AM
Hi vlad,

Sorry for my late response.

Yes this is a Null reference exception. Below are the exception details.

{System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.RadContextMenu.ClearReferences()
   at Telerik.Windows.Controls.RadContextMenu.OnContextMenuChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Telerik.Windows.Controls.RadContextMenu.SetContextMenu(FrameworkElement element, RadContextMenu value)
   at PMUI.Views.Transactions.customerGridView_RowLoaded(Object sender, RowLoadedEventArgs e)}

Message --- "Object reference not set to an instance of an object."
Source --- "Telerik.Windows.Controls.Navigation"

Please let me know if you need any other details.

Regards,
SivaPrasad.B

0
Hristo
Telerik team
answered on 05 May 2011, 01:55 PM
Hello SivaPrasad,

RadContextMenu instance cannot be attached on more then one control. In your scenario you are attaching it on multiple GridViewRows. Even if there is no exception RadContextMenu will be attached only on the last loaded row.
This is a scenario that we want to support but at the moment there are platform limitation.

What you can do is to use single instance of RadContextMenu attached to the RadGridView and changing the ContextMenu items based on the clicked row.

Here is an example:
http://demos.telerik.com/silverlight/#GridView/RowContextMenu

Let us know if you need more details.

Regards,
Hristo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
SivaPrasad Bevara
Top achievements
Rank 1
answered on 10 May 2011, 12:53 PM
Hi Hristo,

Thank you for your response.

As per your response
RadContextMenu instance cannot be attached on more then one control. In your scenario you are attaching it on multiple GridViewRows.

But I am able to do that with the Older version(2010.3.1326.1040) of Telerik controls. I am able to attach different contextmenus with different rows of the Grid.

I am facing problem with the latest version(2011.1.427.1040) of Telerik controls only.
That is also when we move to the neext page. In the first page it is properly attaching the different ContextMenus to the rows.
If your scenario (RadContextMenu instance cannot be attached on more then one control) is correct then it should give error in the first page also. But it is not like that.

Please help.

Regards,
SivaPrasad.B

0
Hristo
Telerik team
answered on 11 May 2011, 07:10 AM
Hi SivaPrasad,

I'm sorry for the misunderstanding. I was left with the impression that you are attaching one instance of RadContextMenu to multiple GridViewRows which is not supported.
Attaching new instances of RadContextMenu to GridViewRow should work.

I've created simple project that attach new contextmenu on every rowloaded but I'm unable to reproduce this exception (attached).
Could you please send us your sample project so that we can investigate what is causing this error?

All the best,
Hristo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
SivaPrasad Bevara
Top achievements
Rank 1
Answers by
Vlad
Telerik team
SivaPrasad Bevara
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or