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

Get ClientDataKeyName from hiecry grid in javascrtip

1 Answer 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric Klein
Top achievements
Rank 1
Eric Klein asked on 07 Apr 2011, 09:00 PM
I have a grid that is a hieracry and uses a panel to load the child

<telerik:RadGrid ID="RadGrid1" AllowFilteringByColumn="true" runat="server" EnableViewState="false" GridLines="None" 
    PagerStyle-AlwaysVisible="true" AllowCustomPaging="true" AllowPaging="true" AllowSorting="true" PageSize="20" Skin="Office2007">
    <clientsettings>
        <ClientEvents OnCommand="RadGrid1_Command" OnHierarchyExpanding="RadGrid1_HierarchyExpanding" />
    </clientsettings>
    <mastertableview hierarchyloadmode="Client" clientdatakeynames="AccessPersonID">
        <AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
        <RowIndicatorColumn><HeaderStyle Width="0px"></HeaderStyle></RowIndicatorColumn>
        <ExpandCollapseColumn Visible="True" ><HeaderStyle Width="0px"></HeaderStyle></ExpandCollapseColumn>
            <Columns>                       
                    ...
                </Columns>
                <NestedViewTemplate>
                </NestedViewTemplate>
    </mastertableview>
</telerik:RadGrid>
  
<asp:Panel ID="Panel1" Style="display: none;" runat="server">
    <telerik:RadGrid ID="RadGrid2" Skin="Office2007" runat="server" EnableViewState="false"
         AllowFilteringByColumn="true" GridLines="None" AllowPaging="true" AllowSorting="true"
         PageSize="10" ShowStatusBar="true">
    <alternatingitemstyle backcolor="#EEEEEE"></alternatingitemstyle>
    <clientsettings>
        <ClientEvents OnCommand="RadGrid2_Command" />
    </clientsettings>
        <mastertableview clientdatakeynames="DocumentLogID" allowfilteringbycolumn="True">
            <Columns>                              
            <telerik:GridBoundColumn SortExpression="ReportName" DataField="ReportName" HeaderText="Report Name" >
                   <FilterTemplate>
                        <telerik:RadComboBox ID="RadComboBoxClientName" DataSourceID="LinqDataSource1" DataTextField="ReportName"
                            DataValueField="ReportName" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ReportName").CurrentFilterValue %>'
                            runat="server" OnClientSelectedIndexChanged="ReportNameIndexChanged" Skin="Office2007">
                            <Items>
                                <telerik:RadComboBoxItem Text="All" Value="" />
                            </Items>
                        </telerik:RadComboBox>
                        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                             <script type="text/javascript">
                                   function ReportNameIndexChanged(sender, args) {
                                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                    if (args.get_item().get_value() == "")
                                       tableView.filter("ReportName", args.get_item().get_value(), "NoFilter");
                                    else
                                       tableView.filter("ReportName", args.get_item().get_value(), "EqualTo");
                                     }
                            </script>
                       </telerik:RadScriptBlock>                                                                            
                </FilterTemplate>                  
              <HeaderStyle Width="200px" />
           </telerik:GridBoundColumn
           <telerik:GridTemplateColumn UniqueName="StatusDescription" SortExpression="StatusDescription" DataField="StatusDescription" HeaderText="Status" >     
              <FilterTemplate>
                   <telerik:RadComboBox ID="RadComboBoxStatus" DataSourceID="LinqDataSource2" DataTextField="StatusDescription"
                       DataValueField="StatusDescription" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("StatusDescription").CurrentFilterValue %>'
                       runat="server"  OnClientSelectedIndexChanged="StatusDescriptionIndexChanged" Skin="Office2007">
                    <Items>
                       <telerik:RadComboBoxItem Text="All" Value="" />
                    </Items>
                  </telerik:RadComboBox>
              <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                 <script type="text/javascript">
                    function StatusDescriptionIndexChanged(sender, args) {
                      var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                      if (args.get_item().get_value() == "")
                         tableView.filter("StatusDescription", args.get_item().get_value(), "NoFilter");
                     else
                         tableView.filter("StatusDescription", args.get_item().get_value(), "EqualTo");
                    }
                </script>
              </telerik:RadScriptBlock>                                    
             </FilterTemplate>                                
             <ItemTemplate>
                <telerik:RadComboBox Runat="server" ID="StatusDropDown" EnableViewState="false" DataTextField="StatusDescription" DataValueField="DocumentStatusID"  
                       DataSourceID="SqlDataSource2" Skin="Office2007"    OnClientSelectedIndexChanged="UpdateDocument" >
               </telerik:RadComboBox>
             </ItemTemplate>    
          </telerik:GridTemplateColumn
           ...                                 
        </Columns>                           
     </mastertableview>
     <pagerstyle alwaysvisible="true" />
   </telerik:RadGrid>
 </asp:Panel>

as you can see I hae a combo box in the child panel that when changed in the grid I want to run an update fo rthe data.

function UpdateDocument(sender, args) {
               var item = args.get_item();
                     Compliance.DocumentLogWS.UpdateDocument(sender.get_errorMessage(), sender.get_value(), DocumentUpdater);                
           }

this works when the grid is jut on layer, but when I am running from the child panel the sender.get_errorMessage() gives me a callback error.  How can I get the the Clientdatakeynames="DocumentLogID" for the row the the combox has been changed.

1 Answer, 1 is accepted

Sort by
0
Eric Klein
Top achievements
Rank 1
answered on 07 Apr 2011, 09:15 PM
Tags
Grid
Asked by
Eric Klein
Top achievements
Rank 1
Answers by
Eric Klein
Top achievements
Rank 1
Share this question
or