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

Grid change in page index, page size and filter causing full postback

1 Answer 206 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 2
Iron
Iron
Veteran
Benjamin asked on 14 Jan 2021, 07:46 AM

I have added my rad grid inside radwindow and radwindow is place inside asp:UpdatePanel. whenever i click on the page link or change the page size or do filter or sorting, it will cause a full postback and radwindow will be closed. Opening the radwindow again, will reflect the change, like grid will reflect the filter result, etc.

how do i prevent this from happening. 

my code

01.<asp:UpdatePanel ID="uPResponder" runat="server" UpdateMode="Conditional">
02.    <ContentTemplate>
03.        <asp:Button ID="btnOpenModal" runat="server" Text="Select user" />
04.        <asp:Label ID="lblUserCount" runat="server"></asp:Label>
05.        <telerik:RadWindow RenderMode="Lightweight" ID="modalPopup" runat="server" CenterIfModal="true" Width="1400px" Height="650px"  Modal="true"
06.        OffsetElementID="main" Style="z-index: 100001;" OnClientClose="countSelected">
07.            <ContentTemplate>
08.                <telerik:RadGrid RenderMode="Lightweight" ClientIDMode="AutoID" CssClass="table" AutoGenerateColumns="false" ID="gvUsers" AllowFilteringByColumn="True" AllowSorting="True" Width="100%"
09.                AllowPaging="True" runat="server" AllowMultiRowSelection="true" OnPreRender="gvUsers_PreRender" OnItemCommand="gvUsers_ItemCommand" OnNeedDataSource="gvUsers_NeedDataSource">
10.                    <PagerStyle Position="TopAndBottom" Mode="NextPrevAndNumeric" PageSizeControlType="RadDropDownList" />
11.                    <MasterTableView DataKeyNames="LoginName" ShowHeader="true" EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true" NoMasterRecordsText="No user found">
12.                    <Columns>
13.                        <telerik:GridTemplateColumn HeaderStyle-Width="10px" AllowFiltering="false" AllowSorting="false" UniqueName="UserCheckbox">
14.                            <HeaderTemplate>
15.                                <asp:CheckBox ID="chbCheckAll"  AutoPostBack="true" runat="server" OnCheckedChanged="chbAll_CheckedChanged" ClientIDMode="AutoID" />
16.                            </HeaderTemplate>
17.                            <ItemTemplate>
18.                                <asp:CheckBox ID="chbUser" runat="server" AutoPostBack="True" CausesValidation="false" Checked='<%# bool.Parse(Eval("isChecked").ToString()) %>'
19.                                OnCheckedChanged="chbUser_CheckedChanged" ClientIDMode="AutoID" />
20.                            </ItemTemplate>
21.                        </telerik:GridTemplateColumn>
22.                        <telerik:GridBoundColumn DataField="Name" HeaderText="Name" ShowSortIcon="true"
23.                        AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
24.                        ShowFilterIcon="true">
25.                        </telerik:GridBoundColumn>
26.                    </Columns>
27.                    </MasterTableView>
28.                </telerik:RadGrid>
29.            </ContentTemplate>
30.        </telerik:RadWindow>                          
31.    </ContentTemplate>
32.</asp:UpdatePanel>

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 18 Jan 2021, 01:24 PM

Hi Benjamin,

Please try to wrap the content of the Window inside an UpdatePanel, instead of wrapping the RadWindow itself:

<telerik:RadWindow RenderMode="Lightweight" ID="RadWindow1" runat="server" CenterIfModal="true" Width="1400px" Height="650px" Modal="true"
    OffsetElementID="main" Style="z-index: 100001;" OnClientClose="countSelected">
    <ContentTemplate>
               
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                    
                <telerik:RadGrid RenderMode="Lightweight" ClientIDMode="AutoID" ..>
                  .....
                </telerik:RadGrid>

            </ContentTemplate>
        </asp:UpdatePanel>

    </ContentTemplate>
</telerik:RadWindow>
In case, the buttons outside of the Window should be used as AsyncPostBackTriggers you can add them to the Triggers collection in the UpdatePanel declaration. You can find some useful information about Ajaxifying controls in the Understanding AJAX Controls article.

The reason for the experienced behavior is that when the ContentTemplatŠµ of the RadWindow is used, the window itself renders as a direct child of the form element when it is first shown so that it can pop up above the other elements without inheriting any restrictions and limitations. Wrapping the entire RadWindow in an update panel with the concept that the controls inside will perform an AJAX request or will be updated by one will no longer work, as they will not be inside the update panel actually. You can find more on this topic in the How to Use RadWindow with AJAX when using the ContentTemplate section in our documentation.

Please try the suggested above and let me know how it goes.

Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Benjamin
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Doncho
Telerik team
Share this question
or