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

inserting child rows into a hierachical grid

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 08 Feb 2010, 11:09 AM
Hi,
 I have a telerik hierachical grid as below and I wish to rows at the child level. However when I click add a new row only rows at the parent level are displayed. How do I go about adding child rows

regards

Robert Smith

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True"  AllowMultiRowEdit="true" AllowPaging="True" AllowAutomaticUpdates="True"
    AllowSorting="True" GridLines="None" DataSourceID="sds_requests_by_status" AutoGenerateColumns="False"  AllowAutomaticInserts="true"
        AutoGenerateHierarchy="True"  OnNeedDataSource="RadGrid1_NeedDataSource" Skin="WebBlue" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCommand="RadGrid1_ItemCommand">
    <MasterTableView DataKeyNames="id"  DataSourceID="sds_requests_by_status" CommandItemDisplay="top"   EditMode="InPlace">
        <DetailTables >
                    <telerik:GridTableView DataKeyNames="id" DataSourceID="sds_products_by_request" Width="100%" runat="server">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="id" MasterKeyField="id" />
                        </ParentTableRelation>
                        <Columns>
                             <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="editcolumn">
                              <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn>
                                  <telerik:GridBoundColumn SortExpression="id" HeaderText="id"  AllowFiltering="false" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="id" UniqueName="id" >
                            </telerik:GridBoundColumn>
                             <telerik:GridBoundColumn  AllowFiltering="false" SortExpression="session_id" HeaderText="session_id"  ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="session_id" UniqueName="session_id" Visible="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  AllowFiltering="false" SortExpression="product_code" HeaderText="product code" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="product_code" UniqueName="product_code">
                            </telerik:GridBoundColumn>
                              <telerik:GridBoundColumn allowfiltering="false" SortExpression="description" HeaderText="description" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="description" UniqueName="description">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn AllowFiltering="false" SortExpression="supplier_code" HeaderText="Supplier code" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="supplier_code" UniqueName="supplier_code">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn AllowFiltering="false" SortExpression="price" HeaderText="Price" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="price" UniqueName="price">
                            </telerik:GridBoundColumn>
                              <telerik:GridBoundColumn allowfiltering="false" SortExpression="currency_code" HeaderText="Currency code" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="currency_code" UniqueName="currency_code">
                            </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn allowfiltering="false"  SortExpression="quantity" HeaderText="Unit quantity" ColumnEditorID="edit_quantity"  HeaderButtonType="TextButton"
                                DataField="quantity" UniqueName="quantity">
                            </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn allowfiltering="false"  ReadOnly="true" Visible="false" SortExpression="" HeaderText="Product_price_id" ColumnEditorID="edit_product_price_id"  HeaderButtonType="TextButton"
                                DataField="Product_Price_Id" UniqueName="Product_Price_Id">
                            </telerik:GridBoundColumn>
                            
                        </Columns>
                    </telerik:GridTableView>
          </DetailTables>            
        <Columns>
              <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="editcolumn">
                    <ItemStyle CssClass="MyImageButton" />
                </telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn DataField="id" DataType="System.Int32" HeaderText="Request No." ReadOnly="True"
                SortExpression="id" UniqueName="id"  >
            </telerik:GridBoundColumn>
            
            <telerik:GridDropDownColumn FilterControlWidth="160px"   DataField="request_status" DataSourceID="sds_request_status"
            HeaderText="Request Status" ListTextField="Request_status" ListValueField="request_status"  Display="false"
            UniqueName="request_status" ColumnEditorID="GridDropDownColumnEditor1">
                        <FilterTemplate>
                            <telerik:RadComboBox ID="RadCbo_Request_status" DataSourceID="sds_request_status" DataTextField="request_status"
                                DataValueField="request_status" Height="200px" AppendDataBoundItems="true"
                                SelectedValue='<%#((GridItem)Container).OwnerTableView.GetColumn("request_status").CurrentFilterValue %>'

                                runat="server" OnClientSelectedIndexChanged="RequestStatusChanged">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                                
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                                <script type="text/javascript">
                                    function RequestStatusChanged(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("request_status", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
                            </telerik:RadScriptBlock>
                        
</FilterTemplate>
             <HeaderStyle Width="160px" />
        </telerik:GridDropDownColumn>
           

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Feb 2010, 03:22 PM
Hi,

Please  take a look at the code library link on how to perform automatic operations in hierarchical grid with SqlDataSource control
Automatic operations in hierarchical grid with SqlDataSource control

Hope this helps.Do let me know if you have any more queries.

Thanks,
Princy




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