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

Refresh data on lower levels of a RadGrid

3 Answers 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lajos
Top achievements
Rank 1
Lajos asked on 24 Oct 2011, 12:49 PM
Hello, Telerik Team,
I have a question about your RadGrid control.

I have a Hierarchical RadGrid with two levels, the markup of the grid looks like this:

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true" AllowCustomPaging="true"
    AllowMultiRowSelection="true">
    <MasterTableView DataKeyNames="ID" ClientDataKeyNames="ID" InsertItemPageIndexAction="ShowItemOnCurrentPage">
        <Columns>
            <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/Images/Icons/Edit.png"
                CommandName="Edit" Text="Edit"
                UniqueName="EditColumn">
            </telerik:GridButtonColumn>
            <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/Images/Icons/Delete.png"
                CommandName="DeleteShift" ConfirmText="Do you want to delete this Shift?" ConfirmDialogHeight="150"
                ConfirmTitle="Confirmation" ConfirmDialogType="RadWindow"
                Text="Delete" UniqueName="DeleteColumn">
            </telerik:GridButtonColumn>
             <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/Images/Icons/AddRecord.png"
                CommandName="AddJob" Text="Add Job"
                UniqueName="AddJob">
            </telerik:GridButtonColumn>
             <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/Images/Icons/ExportCSV.png"
                CommandName="ExportJobsCSV" Text="Export Jobs"
                UniqueName="ExportJobsCSV">
            </telerik:GridButtonColumn>
            <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" Visible="False">
            </telerik:GridBoundColumn>
        </Columns>
        <DetailTables>
            <telerik:GridTableView Width="100%" runat="server" DataKeyNames="ID" ClientDataKeyNames="ID" AllowFilteringByColumn="false" AllowPaging="false" ItemStyle-BackColor="#DCD9C5" AlternatingItemStyle-BackColor="#C0BDAE" AllowSorting="false">
                <%--<ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="ShiftID" MasterKeyField="ID" />
                </ParentTableRelation>--%>
                <Columns>
                   <%-- <telerik:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="~/Images/Icons/Edit.png"
                        HeaderStyle-Font-Size="Smaller" HeaderStyle-Width="34px" HeaderText="Edit" UniqueName="EditColumn" />--%>
                    <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/Images/Icons/Edit.png"
                        CommandName="EditJob"
                        UniqueName="EditColumn" Text="Edit">
                    </telerik:GridButtonColumn>
                    <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/Images/Icons/Delete.png"
                        CommandName="DeleteJob" ConfirmTitle="Confirmation" ConfirmText="Are you sure you want do delete this Job?"
                        ConfirmDialogHeight="150" ConfirmDialogType="RadWindow"
                        Text="Delete" UniqueName="DeleteColumn" />
                </Columns>
            </telerik:GridTableView>
        </DetailTables>
        <CommandItemTemplate>
            <div class="cmdItem">
                <asp:LinkButton ID="btnAddShift" runat="server" CommandName="Add Shift" OnClientClick="javascript:lastTableView=null;">
                    <img alt="" src="../../Images/Icons/AddRecord.png" />Add Shift</asp:LinkButton>   
                <asp:LinkButton ID="btnExportCSV" runat="server" CommandName="Export CSV" OnClientClick="return exportGrid('CSV');"><img alt="" src="../../Images/Icons/ExportCSV.png" />Export to CSV</asp:LinkButton>   
                <asp:LinkButton ID="btnManageShiftColumns" runat="server" CommandName="Manage Shift Columns">
                    <img alt="" src="../../Images/Icons/Columns.png" />Manage Shift Columns</asp:LinkButton>   
                <asp:LinkButton ID="btnManageJobColumns" runat="server" CommandName="Manage Job Columns">
                    <img alt="" src="../../Images/Icons/Columns.png" />Manage Job Columns</asp:LinkButton>   
                <%--<asp:LinkButton ID="btnDetailedExportCSV" runat="server" CommandName="Export CSV Detailed"
                    OnClientClick="return exportGrid('CSVDetailed');"><img alt="" src="../../Images/Icons/ExportCSV.png" />Detailed Export to CSV</asp:LinkButton>   
                <asp:LinkButton ID="btnExportPDF" runat="server" CommandName="Export PDF" OnClientClick="return exportGrid('PDF');"><img alt="" src="../../Images/Icons/ExportPDF.png" />Export to PDF</asp:LinkButton>   --%>
            </div>
        </CommandItemTemplate>
    </MasterTableView>
    <ClientSettings>
        <ClientEvents OnCommand="gridCommand" />
        <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true" />
    </ClientSettings>
</telerik:RadGrid>

The refreshGrid Javascript function looks like this:
function refreshGrid(sender) {
        $find("<%= RadGrid1.ClientID %>").get_masterTableView().rebind();
        showScrollBars();
}

I have a RadWindow where another page is loaded where I can add/delete/modify columns and I have a "sunny day" scenario when the columns in the outer level are changed: the grid is rebinded and the new columns appear nicely. However, when I modify/delete/add columns in the inner levels the grid is rebinded, but the column set in the inner levels is not refreshed. I've debugged the server-side code and everything is fine there, but on the client side I have the old column setup. Is there a solution to my problem, or should I wait for a new version of Telerik?

Note: I've done a temporary hack to hide this anomality from the users where the refreshGrid function only rebinds if the column modification/deletion/insertion happened in the outer layer. Elseway the page is reloaded. I know this is an ugly hack, but I don't see any alternatives.

I appreciate any help.
Sincerely Yours,
Lajos Arpad.

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 26 Oct 2011, 08:20 AM
Hi Lajos,

Note that dynamically changing the grid structure by modifying its columns collection is not supported in this scenario. The only scenario in which changes to the grid columns are supported is when the entire RadGrid is created programmatically from code-behind. Please refer to the Changing the grid structure dynamically on postback help topic to see how RadGrid needs to be defined to support changing columns.

Veli
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Lajos
Top achievements
Rank 1
answered on 26 Oct 2011, 04:13 PM
Thank you, Veli.

Will this be supported in the next version?

Best regards,
Lajos Arpad.
0
Veli
Telerik team
answered on 27 Oct 2011, 08:26 AM
We currently do not have plans on supporting this scenario.

Veli
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Lajos
Top achievements
Rank 1
Answers by
Veli
Telerik team
Lajos
Top achievements
Rank 1
Share this question
or