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

How to fire EditCommand event in hierarchichal grid

4 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dwight
Top achievements
Rank 1
Dwight asked on 09 May 2012, 07:19 AM

Hi

I am using a hierarchical grid to show parent child data, when I update the parent record it is easy to use code behind running on the EditCommand event to grab some values for inserting back in to the record on update and it works well.

However I cant work out how to make the E
ditCommand event to fire in the child grid? I assume that as the DetailTables use another GridView to show the data that it would have access to the same events but I dont know how to access that event in my aspx.vb code

Thx for any advice you can give


Kind regards

Dwight

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 May 2012, 07:33 AM
Hello Dwight,

You can check for EditCommand in ItemCommand event by differentiating MasterTableView and DetailTableView using its Name property.
VB:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
           
    If e.CommandName = RadGrid.EditCommandName AndAlso e.Item.OwnerTableView.Name = "DetailTable1" Then
 'your code
    End If
 If e.CommandName = RadGrid.EditCommandName AndAlso e.Item.OwnerTableView.Name = "Master" Then
'your code
   
End If
End Sub

Thanks,
Shinu.
0
Dwight
Top achievements
Rank 1
answered on 09 May 2012, 08:31 AM

Thx Shinu, that was a very speedy response

I feel that is very close but something is not quite happening right

I used message boxes to return the values from the code that you recommended and got the following - I have highlighted the pieces in your recommended code

MsgBox(e.CommandName) = Edit
MsgBox(e.Item.OwnerTableView.Name) = Blank

It seems that the e.Item.OwnerTableView.Name doesn't have a value, do you have any idea why that would be?

  If e.CommandName = RadGrid.EditCommandName AndAlso e.Item.OwnerTableView.Name"DetailTable1" Then
 'your code
  End If

A simplified version of the markup of the grid declarations is below

<telerik:RadGrid ID="AccountsRadGrid" runat="server"  
        DataSourceID="Accounts" GridLines="None">
            <MasterTableView datakeynames="ID" datasourceid="Accounts">
                <DetailTables>
                    <telerik:GridTableView runat="server" Width="964px" 
            DataKeyNames="ID" DataSourceID="AccountUsers" >

0
Shinu
Top achievements
Rank 2
answered on 09 May 2012, 08:49 AM
Hello Dwight,

Here is the sample code to set the Name property for MasterTableView and DetailTableView.
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" . ..>
  <MasterTableView Name="Master">
     <telerik:GridTableView Name = "DetailTable1" . . >
         . . .
</telerik:RadGrid>

Thanks,
Shinu.
0
Dwight
Top achievements
Rank 1
answered on 09 May 2012, 09:41 AM

Thx so very much Shinu x 1000, that works perfectly :)

I appreciate your expert advice, Telerik controls and support rule \m/


Regards

Dwight
Tags
Grid
Asked by
Dwight
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dwight
Top achievements
Rank 1
Share this question
or