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

Refresh grid upon radWindow event w/ webControls

3 Answers 94 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 23 Jun 2010, 12:52 AM
My project setup is as follows:

Master - content - code generated tab strip - code generated page view - user control page

The master page contains an Ajax manager with an Ajax proxy inside of the user control page

Inside my user control I have a button to open a rad Window defined in the master page, and a rad Grid.  Within the window is a rad upload, and for the post back event I have added functionality to do an insert into my database.

What I would like to do is refresh the grid after I have inserted into my DB.

I have been working with this example:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid

The problem I am having is that I am unable to use code based on the OnAjaxRequest event in the master page because my grid is located in the child control, and the proxy manager can't handle this event, so I'm unable to use the code in the child page.

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
    { 
        if (e.Argument == "Rebind") 
        { 
            RadGrid1.MasterTableView.SortExpressions.Clear(); 
            RadGrid1.MasterTableView.GroupByExpressions.Clear(); 
            RadGrid1.Rebind(); 
        } 
        else if (e.Argument == "RebindAndNavigate") 
        { 
            RadGrid1.MasterTableView.SortExpressions.Clear(); 
            RadGrid1.MasterTableView.GroupByExpressions.Clear(); 
            RadGrid1RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1; 
            RadGrid1.Rebind(); 
        } 
    } 

Thanks for any help


3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 25 Jun 2010, 09:18 AM
Hi Ryan,

For achieving this functionality you could get reference of the UserControl and its inner controls into the main page where the RadAjaxManager is add and use them in The Ajax_Request event. Another suggestion is to us the RadAjaxManager.GetCurrent method to get reference of the AjaxManager in the user control and use its events there. Please refer to the following help topic for more information on these approaches.

I hope this helps.

Greetings,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ryan
Top achievements
Rank 1
answered on 25 Jun 2010, 11:13 PM
I'm at the point now where the Ajax request event will fire, however my grid cannot be found through the following code, and a NullReferenceException occurs.

Body refers to the content place holder on the master page, and FileGrid is the ID of the RadGrid.

C#:
    protected void runAjax(object sender, AjaxRequestEventArgs e) 
    { 
        if (e.Argument == "Rebind") 
        { 
            (Body.FindControl("FileGrid") as RadGrid).MasterTableView.SortExpressions.Clear(); 
            (Body.FindControl("FileGrid") as RadGrid).MasterTableView.GroupByExpressions.Clear(); 
            (Body.FindControl("FileGrid") as RadGrid).Rebind(); 
        } 
        else if (e.Argument == "RebindAndNavigate") 
        { 
            (Body.FindControl("FileGrid") as RadGrid).MasterTableView.SortExpressions.Clear(); 
            (Body.FindControl("FileGrid") as RadGrid).MasterTableView.GroupByExpressions.Clear(); 
            (Body.FindControl("FileGrid") as RadGrid).MasterTableView.CurrentPageIndex = (Body.FindControl("FileGrid") as RadGrid).MasterTableView.PageCount - 1; 
            (Body.FindControl("FileGrid") as RadGrid).Rebind(); 
        } 
    } 

I've also tried sending the clientID of the grid as a parameter to the Ajax event with no success, as shown below:

JS:
    function refreshGrid(arg) { 
            var mgr = $find('<%=RadAjaxManager.GetCurrent(Page).ClientID %>'); 
            mgr.ajaxRequest("<%= FileGrid.ClientID %>") 
    } 

Note that I'm not using the arg parameter as I'm only using the edit functionality and not insert.

C#:
    protected void runAjax(object sender, AjaxRequestEventArgs e) 
    { 
            (Body.FindControl(e.Argument) as RadGrid).MasterTableView.SortExpressions.Clear(); 
            (Body.FindControl(e.Argument) as RadGrid).MasterTableView.GroupByExpressions.Clear(); 
            (Body.FindControl(e.Argument) as RadGrid).Rebind(); 
    } 

Thank you again for your help

Edit - I tried to reference the control as in the provided example however that resulted in a null value as well...


0
Ryan
Top achievements
Rank 1
answered on 28 Jun 2010, 04:24 PM
This problem is solved.  Turns out I missed a reference to the tabstrip section.

Thank you
Ryan
Tags
Ajax
Asked by
Ryan
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or