Fast and quite easy approach for implementing the built-in commands in RadGridView is to set them directly to a particular RadButton. Thus, once you click a single button, the predefined command will be executed.

Basically, there are two main scenarios to define a button - inside and outside the RadGridView. In the first case, you may define it as a CellTemplate of a particular column for example. It will result in a separate RadButton in each row and the command to be executed will be applied to the corresponding item. The definition will be as follows:

            <telerik:RadButton Content="Delete" Command="telerik:RadGridViewCommands.Delete" CommandParameter="{Binding}" /> 
Once the source object is defined up in the tree as a DataContext, you may set the source for the CommandParameter Property's Binding to be the entire object.

The other approach will be to define the RadButton beyond the boundaries of RadGridView:

<telerik:RadButton Width="150" Content="Save insert/edit"  
           CommandTarget="{Binding ElementName=RadGridView1}" /> 

In this case the target object needs to be explicitly set in the definition of the CommandTarget Property, specifying the RadGridView towards which the command has to be applied. This specific command will be automatically disabled untill a change in any of the items in the grid is made.

However, in both cases you will need to initialize the commands beforehand:

public MainPage() 
    ICommand deleteCommand = RadGridViewCommands.Delete; 
    ICommand beginInsertCommand = RadGridViewCommands.BeginInsert; 
    ICommand cancelRowEditCommand = RadGridViewCommands.CancelRowEdit; 
    ICommand commitEditCommand = RadGridViewCommands.CommitEdit; 
In this article
Not finding the help you need? Improve this article