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

RadGrid events (paging, sorting) not firing inside RadWindow

3 Answers 236 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sharepoint Developer
Top achievements
Rank 1
Sharepoint Developer asked on 31 Oct 2011, 08:26 PM
Hi there.

We have a Sharepoint application page and within the main content placeholder we want to host a RadWindow. Opening this window will show the user a search screen where they can enter a couple of parameters and when hitting "search" a Grid will be populated.
If we test the code in a separate page it all works fine, including paging and sorting the Grid's results (we want Ajax postbacks).

However when we have the same markup and same code included within the RadWindow, binding the Grid for the first time works, but then paging and sorting events never happen, the Grid just disappears. Here's the markup (simplified) in the page we're trying it to work:

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnSearchSIC">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="grdTelerik" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="grdTelerik">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="grdTelerik" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

...

    <telerik:RadWindow runat="server" ID="RadWindow_ContentTemplate" Skin="Vista" KeepInScreenBounds="true" VisibleOnPageLoad="false" Modal="true" Title="Search Client"
        Behaviors="Close,Maximize,Move" Width="500" Height="500">
        <ContentTemplate>
            <div>
                SIC Code: <telerik:RadTextBox ID="txtSICCode" runat="server" Text="" EmptyMessage="Enter SIC code" MaxLength="20" ShowButton="false" Skin="Vista"></telerik:RadTextBox><br />
                SIC Description: <telerik:RadTextBox ID="txtSICDescription" runat="server" Text="" EmptyMessage="Enter SIC description" MaxLength="20" ShowButton="false" Skin="Vista"></telerik:RadTextBox><br />
                <telerik:RadButton ID="btnSearchSIC" runat="server" Skin="Vista" Text="Search" ToolTip="Search SIC" AutoPostBack="true" OnClick="btnSearch_Click">
                </telerik:RadButton><br /><br />
                <telerik:RadGrid
                    ID="grdTelerik" runat="server"
                    Skin="Vista"
                    ShowStatusBar="true"
                    AllowSorting="true"
                    AllowPaging="true"
                    PageSize="10"
                    OnSortCommand="grdTelerik_SortCommand"
                    OnPageIndexChanged="grdTelerik_PageIndexChanged">
                        <PagerStyle Mode="NumericPages"></PagerStyle>
                        <MasterTableView ClientDataKeyNames="Amount,Name"></MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true">
                            <Selecting AllowRowSelect="true" />
                            <ClientEvents OnRowDblClick="RowDblClick" />
                        </ClientSettings>
                </telerik:RadGrid>
            </div>
        </ContentTemplate>
    </telerik:RadWindow>

And pretty much the code behind is about binding data to the grid (currently testing with Northwind).
Separately, in a simple ASPX page it all works, but here it doesn't:

        private void LoadData()
        {
            ISampleProvider provider = UnityHelper.Resolve<ISampleProvider>();
            this.grdTelerik.DataSource = provider.GetCustomerOrderHistoryByName("ANTON");
            this.grdTelerik.DataBind();
        }
 
        protected void grdTelerik_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
        {
            LoadData();
        }
 
        protected void grdTelerik_SortCommand(object source, Telerik.Web.UI.GridSortCommandEventArgs e)
        {
            LoadData();
        }
 
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            LoadData();
        }

Any clues on what can be happening? Why are the events not triggering?

Thank you very much.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Nov 2011, 04:27 AM
Hello Jose,

In order to implement advanced features in RadGrid like paging, sorting, grouping etc you should use Advanced data binding using its NeedDataSource event. Check the following help documentation which explains more about this.
Advanced Data-binding (using NeedDataSource event).

-Shinu.
0
Sharepoint Developer
Top achievements
Rank 1
answered on 01 Nov 2011, 05:18 PM
Hi Shinu, thanks for your response, but unfortunately that's not the case.

I can't use OnNeedDataSource because I want the grid to be empty when the RadWindow loads, only populate it when I click the "search" button". In fact I've used the code provided here:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/simplebinding/defaultcs.aspx

as you can see from what I initially posted it's very similar.

Again, if I use the NavigateUrl property of the RadWindow to open the same code in a separate aspx page it all works fine, however if I include the search button and the grid inside the ContentTemplate section of the RadWindow then the second time a postback occurs, it seems the events are not wired anymore.

I mean, the page loads, I can click the search button and see the grid populated via Ajax (no full postback) but then when I try to page or sort the grid results, the grid comes up emtpy (I checked and the server side events to page and sort are not fired).
It seems the AjaxSettings are being lost?

I tried putting all controls into a separate UserControl, then add this to the ContentTemplate of the RadWindow. In the user control I'll add a RadAjaxManagerProxy with my settings, but they're lost when the page loads (?).


0
Sharepoint Developer
Top achievements
Rank 1
answered on 01 Nov 2011, 07:31 PM
Actually I found my problem, it turns out I was populating other controls' datasources then calling this.DataBind() in the page itself.
After I changed to this.whateverControl.DataBind() it all worked nicely.

Thank you.
Tags
Grid
Asked by
Sharepoint Developer
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sharepoint Developer
Top achievements
Rank 1
Share this question
or