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

Editing in a hierarchical grid

3 Answers 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 27 Mar 2018, 08:16 AM

I have a hierarchical parent-child grid where only the child rows can be edited.

When any parent row is expanded I need to have the child rows immediately placed in edit mode.  They also need to retain their values for posting if the parent row is subsequently collapsed, so that all child rows can be enumerated for posting the results.  How would I accomplish that?

Following is the markup for the grid

            <telerik:RadGrid ID="ctlGridAuditSeriesChecklist" runat="server"

                AllowMultiRowEdit="true"
                AllowMultiRowSelection="false"
                AllowPaging="false" 
                AllowSorting="false" 
                AutoGenerateColumns="False"
                BorderColor="#a6a6a6"
                BorderStyle="Solid"
                BorderWidth="0" 
                CellPadding="10" 
                CellSpacing="5"
                CssClass="TUV_grid"
                DataMember="DefaultView"
                DataSourceID="odsGridAuditSeriesChecklist"
                GridLines="Both"
                ImagesPath="~/images/grid"
                ShowFooter="false"
                Width="700px" >
                <ClientSettings
                    EnableAlternatingItems="true"
                    Scrolling-AllowScroll="false"
                    Scrolling-SaveScrollPosition="true"
                    Scrolling-UseStaticHeaders="true" /> 
                <ExportSettings
                    Excel-Format="Xlsx"
                    ExportOnlyData="false"
                    FileName="AuditSeriesReview" 
                    HideStructureColumns="true"
                    IgnorePaging="true"
                    OpenInNewWindow="true" />
                <MasterTableView
                    DataKeyNames="AuditID"
                    CommandItemDisplay="Top"
                    EditMode="InPlace" >
                    <CommandItemTemplate>
                        <span class="TUV_gridHeader">Audit Series Review Checklist</span>
                    <telerik:RadButton ID="btnExportToPDF" runat="server"
                        CommandName="ExportToPDF"
                        Icon-PrimaryIconUrl="~/images/ExportToPDF.gif"
                        Text="Export To PDF" />
                    <telerik:RadButton ID="btnExportToExcel" runat="server"
                        CommandName="ExportToExcel"
                        Icon-PrimaryIconUrl="~/images/ExportToExcel.gif"
                        Text="Export To Excel" />
                    <telerik:RadButton ID="btnExportToCSV" runat="server"
                        CommandName="ExportToCSV"
                        Icon-PrimaryIconUrl="~/images/ExportToCsv.gif"
                        Text="Export To CSV" />
                    </CommandItemTemplate>
                    <Columns>
                        <telerik:GridBoundColumn 
                            DataField="CARMajorCount"
                            DataType="System.Int32"
                            HeaderText="CAR Major Count"
                            UniqueName="CARMajorCount"
                            ReadOnly="true" />
                        <telerik:GridBoundColumn 
                            DataField="CARMinorCount"
                            DataType="System.Int32"
                            HeaderText="CAR Minor Count"
                            UniqueName="CARMinorCount"
                            ReadOnly="true" />
                        <telerik:GridBoundColumn 
                            DataField="CARUploadCount"
                            DataType="System.Int32"
                            HeaderText="CAR Upload Count"
                            UniqueName="CARUploadCount"
                            ReadOnly="true" />
                        <telerik:GridBoundColumn 
                            DataField="CARAppealCount"
                            DataType="System.Int32"
                            HeaderText="CAR Appeal Count"
                            UniqueName="CARAppealCount"
                            ReadOnly="true" />
                        <telerik:GridBoundColumn 
                            DataField="CARApprovalCount"
                            DataType="System.Int32"
                            HeaderText="CAR Approval Count"
                            UniqueName="CARApprovalCount"
                            ReadOnly="true" />
                        <telerik:GridBoundColumn 
                            DataField="CARStatusText"
                            DataType="System.String"
                            HeaderText="CAR Status"
                            UniqueName="CARStatusText"
                            ReadOnly="true" />
                        <telerik:GridButtonColumn
                            ButtonType="ImageButton"
                            UniqueName="CARs"
                            CommandName="CARs" 
                            HeaderText="CARs" 
                            ItemStyle-HorizontalAlign="Center"
                            ItemStyle-Wrap="false" />
                        <telerik:GridBoundColumn 
                            DataField="AuditID"
                            DataType="System.Int32"
                            Visible="false" />
                    </Columns>
                    <DetailTables>
                        <telerik:GridTableView runat="server"
                            DataKeyNames="AuditReviewID"
                            DataSourceID="odsGridAuditSeriesChecklistSub"
                            AllowPaging="false" 
                            AllowSorting="false"
                            PagerStyle-AlwaysVisible="false"
                            Width="96%" >
                            <ParentTableRelation>
                                <telerik:GridRelationFields
                                    DetailKeyField="AuditID"
                                    MasterKeyField="AuditID" />
                            </ParentTableRelation>
                            <Columns>
                                <telerik:GridBoundColumn 
                                    DataField="DocumentName"
                                    DataType="System.String"
                                    HeaderText="DocumentName"
                                    ReadOnly="true" />
                                <telerik:GridBoundColumn 
                                    DataField="Need"
                                    DataType="System.String"
                                    UniqueName="Need"
                                    HeaderText="Need"
                                    ReadOnly="true" />
                                <telerik:GridCheckBoxColumn 
                                    DataField="AdminReview"
                                    DataType="System.Boolean"
                                    UniqueName="AdminReview"
                                    HeaderText="A/R"
                                    ItemStyle-Wrap="true" />
                                <telerik:GridCheckBoxColumn 
                                    DataField="MainReview"
                                    DataType="System.Boolean"
                                    UniqueName="MainReview"
                                    HeaderText="M/R"
                                    ItemStyle-Wrap="true" />
                                <telerik:GridTemplateColumn
                                    DataField="TechReview"
                                    HeaderText="Yes No N/A Corr"
                                    UniqueName="TechReview"
                                    HeaderStyle-Wrap="false"
                                    ItemStyle-Wrap="false" >
                                    <EditItemTemplate>
                                        <asp:RadioButtonList ID="optTechReview" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                                            <asp:ListItem Text = "" Value="Yes" />
                                            <asp:ListItem Text = "" Value="No" />
                                            <asp:ListItem Text = "" Value="NA" />
                                            <asp:ListItem Text = "" Value="Corr" />
                                        </asp:RadioButtonList>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn 
                                    DataField="Remarks"
                                    UniqueName="Remarks"
                                    HeaderText="Remarks" 
                                    DataType="System.String"/>

                                <telerik:GridBoundColumn 
                                    DataField="AuditReviewID"
                                    DataType="System.Int32"
                                    Visible="false" />
                            </Columns>
                        </telerik:GridTableView>
                    </DetailTables>
                </MasterTableView>
            </telerik:RadGrid>

    <asp:ObjectDataSource ID="odsGridAuditSeriesChecklist" runat="server" 
        TypeName="GridAuditorMainReview_Checklist"
        DataObjectTypeName="GridAuditorMainReview_Checklist.Bean"
        EnablePaging="True"
        SelectCountMethod="GetRecordCount"
        SelectMethod="GetRecords" 
        SortParameterName="SortExpression" >
    </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="odsGridAuditSeriesChecklistSub" runat="server" 
        TypeName="GridAuditorMainReview_Checklist_Sub"
        DataObjectTypeName="GridAuditorMainReview_Checklist_Sub.Bean"
        SelectCountMethod="GetRecordCount"
        SelectMethod="GetRecords" >
        <SelectParameters>
            <asp:SessionParameter Name="AuditID" SessionField="AuditID" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>

3 Answers, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 10 Apr 2018, 08:07 AM
Hi Richard,

Try to set the Hierarchy Load mode to Client after which subscribe the RadGrid to its PreRender event where you can loop through the grid items and put the NestedTableView-items into Edit mode.

Consider the following Markup
<telerik:RadGrid ID="RadGrid1" runat="server" OnPreRender="RadGrid1_PreRender">
    <MasterTableView HierarchyLoadMode="Client"></MasterTableView>
</telerik:RadGrid>

VB - Code behind
Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs)
    For Each dataItem As GridDataItem In DirectCast(sender, RadGrid).MasterTableView.Items
        If dataItem.HasChildItems Then
            Dim nestedTableView As GridTableView = dataItem.ChildItem.NestedTableViews(0)
            For Each item As GridItem In nestedTableView.Items
                If TypeOf item Is GridEditableItem Then
                    Dim editableItem As GridEditableItem = CType(item, GridDataItem)
                    editableItem.Edit = True
                End If
            Next
            nestedTableView.Rebind()
        End If
        dataItem.Expanded = False
    Next
End Sub

Below you can find the references to help articles that we used to create this scenario:

Also, attached you can find a sample page demonstrating the above. Please give it a try to see if that works for you.

I hope this will prove helpful.

Kind regards,
Attila Antal
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Richard
Top achievements
Rank 1
answered on 10 Apr 2018, 01:35 PM

Thanks - I have been having problems getting this working, and will try your suggestions.

Will let you know if I can get this working

0
Attila Antal
Telerik team
answered on 10 Apr 2018, 02:47 PM
Hi Richard,

Please, take your time.

We'll be here to assist you!

Kind regards,
Attila Antal
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Richard
Top achievements
Rank 1
Share this question
or