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

Getting dataKeyvalue from 3 nested radgrid

2 Answers 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rodrigo
Top achievements
Rank 1
Rodrigo asked on 06 Sep 2015, 04:26 PM

Hi,

I´m delaing with some trouble; here is the topic: I have a 3 nested radgrid:

<telerik:RadGrid ID="radGridEquipos" runat="server" ShowStatusBar="True" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True"                                     OnDetailTableDataBind="radGridEquipos_DetailTableDataBind" OnNeedDataSource="radGridEquipos_NeedDataSource"                                     Width="100%" GroupPanelPosition="Top" Skin="MetroTouch" Culture="es-MX" OnDataBound="radGridEquipos_DataBound" AllowFilteringByColumn="True" PageSize="15" OnSelectedIndexChanged="radGridEquipos_SelectedIndexChanged" AllowMultiRowSelection="True" MasterTableView-HierarchyLoadMode="ServerBind">                                     <PagerStyle AlwaysVisible="True" EnableSEOPaging="True" Mode="Slider" PageButtonCount="5"></PagerStyle>                                     <ClientSettings>                                         <ClientEvents OnRowSelected="itemSelected" />                                         <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="2" ScrollHeight="590"></Scrolling>                                         <Selecting AllowRowSelect="True" />                                     </ClientSettings>                                     <MasterTableView DataKeyNames="ID_Equipo" AllowMultiColumnSorting="True">                                         <DetailTables>                                             <telerik:GridTableView DataKeyNames="ID_Equipo" Name="Sistema" Width="100%" AllowPaging="False">                                                 <DetailTables>                                                     <telerik:GridTableView DataKeyNames="ID_Equipo" Name="Componente" Width="100%" AllowPaging="False">                                                         <Columns>                                                             <telerik:GridBoundColumn SortExpression="ID_Equipo" HeaderText="ID" HeaderButtonType="TextButton"                                                                 DataField="ID_Equipo" Visible="false">                                                             </telerik:GridBoundColumn>                                                             <telerik:GridBoundColumn SortExpression="Denominacion" HeaderText="Componente" HeaderButtonType="TextButton"                                                                 DataField="Denominacion" FilterControlWidth="100%">                                                             </telerik:GridBoundColumn>                                                         </Columns>                                                         <PagerStyle AlwaysVisible="True" Mode="Slider" PageButtonCount="5" />                                                     </telerik:GridTableView>                                                 </DetailTables>                                                 <Columns>                                                     <telerik:GridBoundColumn SortExpression="ID_Equipo" HeaderText="ID" HeaderButtonType="TextButton"                                                         DataField="ID_Equipo" Visible="false">                                                     </telerik:GridBoundColumn>                                                     <telerik:GridBoundColumn SortExpression="Denominacion" HeaderText="Sistema" HeaderButtonType="TextButton"                                                         DataField="Denominacion" FilterControlWidth="100%">                                                     </telerik:GridBoundColumn>                                                 </Columns>                                                 <PagerStyle AlwaysVisible="True" Mode="Slider" PageButtonCount="5" />                                             </telerik:GridTableView>                                         </DetailTables>                                         <Columns>                                             <telerik:GridBoundColumn SortExpression="ID_Equipo" HeaderText="ID" HeaderButtonType="TextButton"                                                 DataField="ID_Equipo" Visible="false">                                             </telerik:GridBoundColumn>                                             <telerik:GridBoundColumn SortExpression="Denominacion" HeaderText="Equipo" HeaderButtonType="TextButton"                                                 DataField="Denominacion" FilterControlWidth="100%">                                             </telerik:GridBoundColumn>                                         </Columns>                                         <PagerStyle AlwaysVisible="True" Mode="Slider" PageButtonCount="5" />                                     </MasterTableView>                                 </telerik:RadGrid>

what I need is to get the id of whatever row is selected on the grid and nested grids.

Can you team help me please?​

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 10 Sep 2015, 07:12 AM
Hi Rodrigo,

In order to obtain the ID data field that you are setting in the DataKeyNames collections, you could either use the client-side data item or the server-side GridDataItem object and use the GetDataKeyValue method.

For detailed information on the client-side and server-side APIs you can refer to our online documentation.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Rodrigo
Top achievements
Rank 1
answered on 10 Sep 2015, 03:20 PM

Thanks Konstantin,

 I figured it out, I created in the client-side a function and i got the values.

<PagerStyle AlwaysVisible="True" EnableSEOPaging="True" Mode="Slider" PageButtonCount="5"></PagerStyle>
                                    <ClientSettings>
                                        <ClientEvents OnRowSelected="itemSelected" />
                                        <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="2" ScrollHeight="590"></Scrolling>
                                        <Selecting AllowRowSelect="True" />
                                    </ClientSettings>

function itemSelected(sender, eventArgs) {
            var grid = $find("<%=radGridEquipos.ClientID %>");
            var id;
            var textbox = $find('<%= radTxtEquipo.ClientID %>');
            if (grid.get_masterTableView().get_selectedItems().length < 1)
            {
                if (eventArgs.get_tableView().get_name() == "Sistema") {
 
                    var evt = eventArgs.get_domEvent();
                    var GetNewValue = eventArgs.getDataKeyValue("ID_Equipo");
                     
                    id = GetNewValue;
                    textbox.set_value(id);
                    var y = document.getElementById('<%= hdf2.ClientID %>');
                    y.value = id;
                }
                if (eventArgs.get_tableView().get_name() == "Componente") {
 
                    var evt = eventArgs.get_domEvent();
                    var GetNewValue = eventArgs.getDataKeyValue("ID_Equipo");
                     
                    id = GetNewValue;
                    textbox.set_value(id);
                    var z = document.getElementById('<%= hdf3.ClientID %>');
                    z.value = id;
                }
            }
            else {
                id = grid.get_masterTableView().get_selectedItems()[0].getDataKeyValue("ID_Equipo");
                 
               textbox.set_value(id);
               var x = document.getElementById('<%= hdf1.ClientID %>');
                   x.value = id;
 
               }
           }

Tags
Grid
Asked by
Rodrigo
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Rodrigo
Top achievements
Rank 1
Share this question
or