your demo :
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
Margin="0,5,0,0">
<telerik:RadButton Width="150"
Content="Delete selected rows"
Margin="0,0,5,0"
Command="telerikGrid:RadGridViewCommands.Delete"
CommandTarget="{Binding ElementName=RadGridView1}" />
<telerik:RadButton Width="150"
Content="Add new row"
Margin="0,0,5,0"
Command="telerikGrid:RadGridViewCommands.BeginInsert"
CommandTarget="{Binding ElementName=RadGridView1}" />
<telerik:RadButton Width="150"
Content="Save insert/edit"
Margin="0,0,5,0"
Command="telerikGrid:RadGridViewCommands.CommitEdit"
CommandTarget="{Binding ElementName=RadGridView1}" />
<telerik:RadButton Width="150"
Content="Cancel insert/edit"
Command="telerikGrid:RadGridViewCommands.CancelRowEdit"
CommandTarget="{Binding ElementName=RadGridView1}" />
</StackPanel>
8 Answers, 1 is accepted
I am afraid that you cannot extend the built-in commands, but you could subscribe for the proper events raised on their execution. For example for the Delete command those will be the Deleting/Deleted events of the RadGridView. Once they are raised you could execute any additional logic. Do you think this would be a working solution for your scenario?
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
The event that corresponds to the BeginInsert command would be the AddingNewDataItem event of the RadGridView. You could use a WPF Attached Behavior for the GridView and handle the events that way.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Our company buy telerik control to speed up development. We can implement the requirement without telerik. But since we have chosen telerik, we want to use telerik in the right way. So a formal version demo is needed. And we need the demo to show two stages validation. First stage, the row is validated by viewmodel or something like validationRule. Second stage, the row is commited to database, database refuse it, we want the error message can show aside the row. It is a common scenario. Please provide sample.
May I ask you to share a little bit more details on how do you connect/interact with the database?
Greetings,Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Generally RadGridView supports various data validation methods like IDataErrorInfo + INotifyPropertyChanged, INotifyDataErrorInfo and DataAnnotation attributes. They provide information about errors and RadGridView will show "red borders" accordingly.
You can validate on data level implementing INotifyDataErrorInfo interface for your ViewModel/business object. Please check this help article for details. Furthermore I have as well attached a sample project demonstrating such a validation (via INotifyDataErrorInfo).
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Hi, its 2 years to late but maybe someone need them in future.
i think the answer about Events 2 Commands is given here
http://docs.telerik.com/devtools/wpf/common-event-to-command-behavior.html
br