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

Commands from GridTableView??

2 Answers 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Casey
Top achievements
Rank 1
Casey asked on 11 Mar 2010, 04:44 PM
Hello,

I'm having difficulties when trying to add the following functionality to my RadGrid.

I have a RadGrid with a GridTableView inside the DetailTables section of the RadGrid. I've set the CommandItemDisplay so the commands are visible to the user; however, when a command is used, like "Add New Record", the Master Grid's ItemCommand event is fired and the CommandName is "InitInsert". The issue I have is that the master RadGrid also has commands, which will insert/update/delete records in a different table than the GridTableView Commands would update records in. I have been unable to determine how to identify whether or not the command is coming from the Master RadGrid or the GridTableView. Is there a way to determine that the user clicked the DELETE command of the detail table and not of the master table?

Any assistance would be appreciated.

Thanks!
Casey

2 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 11 Mar 2010, 05:29 PM
Hello Casey,

You could try adding the different values to the MasterTableView.Name and GridTableView.Name properties:
<MasterTableView DataSourceID="SqlDataSource1" CommandItemDisplay="Top" DataKeyNames="CustomerID" Name="Master" >
...
<MasterTableView DataSourceID="SqlDataSource1" CommandItemDisplay="Top" DataKeyNames="CustomerID" Name="Master" AllowMultiColumnSorting="True">
   <DetailTables>
       <telerik:GridTableView CommandItemDisplay="Top" Name="Child" DataKeyNames="OrderID" DataSourceID="SqlDataSource2" runat="server">

Then in the RadGrid.ItemCommand event handler you could find which CommandItem fired the command, by checking if the GridCommandItem.OwnerTableView.Name property is "Master" or "Child":

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
   if ((e.Item as GridCommandItem).OwnerTableView.Name == "Master")
   {
     // MasterTable's InitInsertCommand is fired
   }
   else
   {
     // GridTableView's InitInsertCommand is fired
   }
}

Additionally I am sending you a simple example which illustrates the desired functionality.

Greetings,
Radoslav
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
Jack
Top achievements
Rank 1
answered on 10 Oct 2012, 06:23 AM
it really works!
Tags
Grid
Asked by
Casey
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Jack
Top achievements
Rank 1
Share this question
or