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

Hierarchy Client Side DataKeyValue

2 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 15 Aug 2009, 03:34 PM

Hello all.  I am currently having a problem getting the DataKeyValue from
my DetailTables data.  The MasterTableView works fine, however, the
same logic does not work with DetailTables.  I have searched the forum
and cannot fine any reference to this problem before.  Anyone have any
clues?  Code posted below.  Thanks in advance.

<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" Width="97%" AutoGenerateColumns="False"  AllowSorting="True"  ShowStatusBar="true" Skin="Office2007">  
<MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="EventID" AllowMultiColumnSorting="True" Width="100%" Name="EventTable" ClientDataKeyNames="EventID">  
<DetailTables> 
<telerik:GridTableView DataKeyNames="DataID" DataSourceID="SqlDataSource2" 
runat="server" Width="100%" TableLayout="Fixed" Name="DataTable" ClientDataKeyNames="DataID">  
<ParentTableRelation> 
<telerik:GridRelationFields DetailKeyField="EventID" MasterKeyField="EventID" /> 
</ParentTableRelation> 
<Columns> 
<telerik:GridBoundColumn HeaderText="Data ID" DataField="DataID" /> 
<telerik:GridBoundColumn HeaderText="Requirement" DataField="DataReqr" /> 
<telerik:GridBoundColumn HeaderText="Unit Sourced" DataField="DataUS" /> 
</Columns> 
</telerik:GridTableView> 
</DetailTables> 
<Columns> 
<telerik:GridBoundColumn HeaderText="Name" DataField="EventName" HeaderStyle-Width="200px" /> 
<telerik:GridBoundColumn HeaderText="Event AOR" DataField="EventAOR" HeaderStyle-Width="200px" />        
</Columns> 
<GroupByExpressions> 
<telerik:GridGroupByExpression> 
<SelectFields> 
<telerik:GridGroupByField FieldAlias="FY" FieldName="EventFY" /> 
</SelectFields> 
<GroupByFields> 
<telerik:GridGroupByField FieldName="EventFY" /> 
</GroupByFields> 
</telerik:GridGroupByExpression> 
</GroupByExpressions> 
</MasterTableView> 
<ClientSettings ReorderColumnsOnClient="True" AllowColumnsReorder="True">  
<ClientEvents OnRowClick="RowClicked" /> 
<Selecting AllowRowSelect="true" /> 
</ClientSettings> 
</telerik:RadGrid> 
<script type="text/javascript">  
    function RowClicked(sender, args) {  
        if(args.get_tableView().get_name() == "EventTable")  
           alert(args.getDataKeyValue("EventID"));  
       if (args.get_tableView().get_name() == "DataTable")  
           alert(args.getDataKeyValue("EventID"));  
         
    }  
</script> 

Joshua

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 17 Aug 2009, 06:31 AM
Hi Joshua,

In your code, I find that you are using the wrong ClientDataKeyName for teh DetailTable. Since you have set the ClientDataKeyNames for the detailtable as DataID, youhave to pass the same field name in the code to access the key value on client:
js:
function RowClicked(sender, args)  
   {   
        if(args.get_tableView().get_name() == "EventTable")   
           alert(args.getDataKeyValue("EventID"));   
        if (args.get_tableView().get_name() == "DataTable")   
           alert(args.getDataKeyValue("DataID"));   
          
    }   

Thanks
Princy.
0
Josh
Top achievements
Rank 1
answered on 17 Aug 2009, 09:32 AM
How on earth did I miss that?  You would think I would have caught it
after staring at that little piece code for 10 minutes.  I will check it
out when I get home today.  Thanks Princy.

Joshua
Tags
Grid
Asked by
Josh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Josh
Top achievements
Rank 1
Share this question
or