my data are validated in a ViewModel, which implements INotifyDataErrorInfo.
The data are changed via code, if an error occurs the row does not reflect that error
(if i step in the cell the error is shown).
I must call items.refresh to trigger the estimated behavior, but it seems not to be the right way.
Are there any other solutions?
Greatings
Ralf
6 Answers, 1 is accepted
Generally there would not be such a problems. The RadGridView have a mechanism to listen for the INotifyDataErrorInfo.ErrorsChanged event of its underlying objects.
We would need more detailed description of the particular scenario to figure out what would be wrong. How does your ViewModel implement the INotifyDataErrorInfo? Do you have some custom bindings?
Didie
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
i am loading cell templates at runtime because i must generate columns on the fly.
here my generic template:
var sb =
new
StringBuilder();
sb.Append(
"<DataTemplate "
);
sb.Append(
"xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "
);
sb.Append(
"xmlns:this='clr-namespace:TelerikClient;assembly=TelerikClient' "
);
sb.Append(
"xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>"
);
sb.AppendFormat(
"<this:{0} DataContext=\"{{Binding [{1}] }}\" />"
, control, uniqueName);
sb.Append(
"</DataTemplate>"
);
return
XamlReader.Load(sb.ToString())
as
DataTemplate;
You can see that i am binding an Indexer Property from the ViewModel. The Indexrr Property is also a ViewModel.
Both ViewModels (for row and for indexer) have the same ViewModelBase with INotifyDataErrorInfo implemented.
The Error will be created in the Indexer Property.
Control is a specific UserControl with the relevant Bindings. Here the one Part from the Control:
<telerik:RadNumericUpDown
Visibility=
"{Binding Path=IsReadOnly, Converter={StaticResource vConverterInverse}, FallbackValue=Collapsed}"
Margin=
"10,0,0,0"
Value=
"{Binding NewPrice, Mode=TwoWay}"
NumberDecimalDigits=
"3"
SmallChange=
"0.01"
/>
If a user edit the property in the cell all is ok, the error is shown like expected.
But if i am changing the property in code nothing happens, here i must refresh the grid.
Not very helpfull ?
ralf
OK - opened a ticket 462423 with attached project.
As I have answered in your other post, the validation errors are not shown as you use a custom binding. In your case, you have binding to a property of the underlying property.
Due to a performance optimization, the RadGridView is only listening for a notifications from its direct underlying objects. The notification of the property on the second level never goes to the GridView.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
i am not sure what you meaning with custom binding.
Its a binding to an indexer property and behind this property i have another viewmodel.
I understand that you optimize your grid, but if i change the property directly in the grid cell the error
propagate correctly to the row ?!
Hm .. please tell me if i made a mistake with my thinking.
Sorry, i did not saw your answer on the atoher post.
Please ignore this reply.
Bye Ralf
For the understanding of anyone interested in a similar problem, here I will post the explanation that I have answered to you in your other post.
If you have Items bound to the GridView. Then each of this Item has Child and the Name of the Child is bound to a specific column(the column is bound to Child.Name).This is a custom binding. When the change of the value (of the Name property) is done in Edit mode (from the UI), then we know what object it is and the GridView handles its notifications. When the change of the value is done in ViewMode, then only the notifications raised by the most parent property (i.e. the ones from the Item.Child property that is directly underlying in the GridView) are handled.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I am implementing a change in my Cell DataTemplateSelector but we're already at our wits end with the performance of the grid when templating cells...
If there's a way to get this to work without a Template, please explain what needs to happen.