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

Adding childrows to a hierachy grid

1 Answer 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 04 Feb 2010, 04:49 PM
Hi,
    How do I add child rows to a hierachy grid, without allowing inserts to the Parent table. I have put Allowautotmaticinserts = "true"
in the properties and this Just seems to allow me to add a top level row, there is now "Add new Row" add the child level.

The html for the grid is as below
<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">
    <MasterTableView DataKeyNames="id"   DataSourceID="sds_requests_by_status" 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"  ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="id" UniqueName="id" >
                            </telerik:GridBoundColumn>
                             <telerik:GridBoundColumn SortExpression="session_id" HeaderText="session_id"  ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="session_id" UniqueName="session_id" Visible="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="product_code" HeaderText="product code" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="product_code" UniqueName="product_code">
                            </telerik:GridBoundColumn>
                              <telerik:GridBoundColumn SortExpression="description" HeaderText="description" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="description" UniqueName="description">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="supplier_code" HeaderText="Supplier code" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="supplier_code" UniqueName="supplier_code">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="price" HeaderText="Price" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="price" UniqueName="price">
                            </telerik:GridBoundColumn>
                              <telerik:GridBoundColumn SortExpression="currency_code" HeaderText="Currency code" ReadOnly="true" HeaderButtonType="TextButton"
                                DataField="currency_code" UniqueName="currency_code">
                            </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="quantity" HeaderText="Unit quantity" ColumnEditorID="edit_quantity"  HeaderButtonType="TextButton"
                                DataField="quantity" UniqueName="quantity">
                            </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="" HeaderText="Product_price_id" ColumnEditorID="edit_product_price_id"  HeaderButtonType="TextButton"
                                DataField="Product_Price_Id" UniqueName="Product_Price_Id">
                            </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="" HeaderText="user_id"  ReadOnly="true"  HeaderButtonType="TextButton"
                                DataField="user_id" UniqueName="user_id">
                            </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="" HeaderText="user_identity"  ReadOnly="true"  HeaderButtonType="TextButton"
                                DataField="user_identity" UniqueName="user_identity">
                            </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"
            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>
            
         <%--   
              <telerik:GridBoundColumn DataField="request_status" HeaderText="Status" SortExpression="request_status"
                UniqueName="request_status">
            </telerik:GridBoundColumn>--%>
              <telerik:GridBoundColumn DataField="request_date" DataType="System.DateTime" ReadOnly="true" HeaderText="Request Date" SortExpression="request_date"
                UniqueName="request_date">
            </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="price" DataType="System.Decimal" ReadOnly="true"  HeaderText="Value"
                SortExpression="price" UniqueName="price">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="first_name"  HeaderText="Submitter First Name" ReadOnly="true"
                SortExpression="first_name" UniqueName="first_name">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="last_name"  HeaderText="Submitter Last Name" ReadOnly="true"
                SortExpression="last_name" UniqueName="last_name">
            </telerik:GridBoundColumn>
        </Columns>
         <ExpandCollapseColumn Visible="True">
            </ExpandCollapseColumn>
    </MasterTableView>
    <ClientSettings>
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
</telerik:RadGrid>

Thanks
Robert Smith

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 05 Feb 2010, 09:27 AM
Hello Robert,

AllowAutomaticInserts means that when you insert a new row into the grid (through the Insert form opened by the "Add new Row" button) the grid will automatically update the underlying data-source. Other than that, you cannot insert any rows into the grid manually without first adding them to the underlying data source and rebinding the grid to it.

I hope this information helps.

Best wishes,
Tsvetoslav
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or