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

Radajaxmanager on masterpage and refreshing radgrid on a user conrol using it

2 Answers 210 Views
Grid
This is a migrated thread and some comments may be shown as answers.
inanc
Top achievements
Rank 1
inanc asked on 02 Apr 2010, 03:33 PM

Posted 19 hours ago (permalink)

Hi,
I've been looking for the demo application given on the url:

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid

A snippet for that demo:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
            function ShowEditForm(id, rowIndex)
            {
                var grid = $find("<%= RadGrid1.ClientID %>");
                
                var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
                grid.get_masterTableView().selectItem(rowControl, true);
                        
                window.radopen("EditFormCS.aspx?EmployeeID=" + id, "UserListDialog");
                return false;
            }
            function ShowInsertForm()
            {
               window.radopen("EditFormCS.aspx", "UserListDialog");
               return false;
            }
            function refreshGrid(arg)
            {
             if(!arg)
             {
             $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");            
                }
                else
                {
             $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");            
                }
            }

            function RowDblClick(sender, eventArgs)
            {
             window.radopen("EditFormCS.aspx?EmployeeID=" + eventArgs.getDataKeyValue("EmployeeID"), "UserListDialog");
            }
            </script>
        </telerik:RadCodeBlock>


And I could not understand what form element or event fires the function function refreshGrid(arg)
I think, It should be called in  the onClientClose() of the radwindow.Does the given sample  code has some missed parts?

I am trying to run that sample on Sitefinity. But I could not yet.
Shortly the code that I use:

<telerik:RadCodeBlock  ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function ShowEditForm(id, rowIndex) {

                    window.radopen("UserControls/Pages/PaketKapsaminaAlma.aspx?IstId=" + id, "UserListDialog");
                    return false;
                }
                function ShowInsertForm() {

                    window.radopen("UserControls/Pages/PaketKapsaminaAlma.aspx", "UserListDialog");
                    return false;
                }
                function refreshGrid(arg) {
                    
                        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
                
                function RowDblClick(sender, eventArgs) {
                    window.radopen("UserControls/Pages/Istek.PaketKapsaminaAlma?IstId=" + eventArgs.getDataKeyValue("ISTID"), "UserListDialog");
                }
            </script>
        </telerik:RadCodeBlock>


and I call the function refreshGrid(arg) on OnClientClose of RadWindow with ID UserListDialog

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    <Windows>
        <telerik:RadWindow ID="UserListDialog" runat="server" Title="Paket kapsamına alma" Height="300px"
            Width="300px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" OnClientClose="refreshGrid"
            Modal="true" />
    </Windows>
</telerik:RadWindowManager>

my AjaxRequest function on cs file is:

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Rebind")
        {
            BindMyGrid();//this is my function to bind the grid
           // rdgvIstektenAramaSonuclari.MasterTableView.SortExpressions.Clear();
            //rdgvIstektenAramaSonuclari.MasterTableView.GroupByExpressions.Clear();
            //rdgvIstektenAramaSonuclari.Rebind();
         }
    }  


When  I used the recomended lines below  there were no action

            // rdgvIstektenAramaSonuclari.MasterTableView.SortExpressions.Clear();
            //rdgvIstektenAramaSonuclari.MasterTableView.GroupByExpressions.Clear();
            //rdgvIstektenAramaSonuclari.Rebind();

It works great with my BindMyGrid() function which binds the grid with the related datasource of mine. But it works only once :( .

When  I click the linkbutoton on the grid that opens radwindow no problem with it. And when I close the radwindow, it refreshs the grid perfectly..:) And I push the similar linkbutton on the grid to open the radwindow . And  no problem again. But when I update  the data belong  to grid and close the radwindow, it says that:

Microsoft JScript runtime error: 'null' is null or not an object


the problem is on the
 function refreshGrid(arg) {
                    
                        $find("ctl00_cntUst_ctl00_RadAjaxManager1").ajaxRequest();
                }

 code can't find the object for the second onclientclose event of the radwindow. I've looked everywhere on the forums related with that topic. But I have no solution yet.

I think the solution is using a Radajaxmanager on masterpage. But in that case I should reach the radgrid on the user control.

How can I reference a radgrid on a user control from a masterpage in sitefinity.
Any idea?
Regards

2 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 20 May 2010, 02:07 AM
Hi,

I'm trying to get the same example working.  You seem like you're working through the same steps I am so I suspect you've already figured out the following:

I originally had refreshGrid moved the in the radwindow but moved it to the radWindowManager, so that fires at the correct time now.

In refreshGrid, I changed the $find statement to

$find(

"<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(this.Page).ClientID %>").ajaxRequest("Rebind");

I register in the code behind with:

 

Telerik.Web.UI.

RadAjaxManager.GetCurrent(this.Page).AjaxRequest += new Telerik.Web.UI.RadAjaxControl.AjaxRequestDelegate(RadAjaxManager_AjaxRequest);

 


and have the corresponding in the code behind:

 

void RadAjaxManager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)

 

{...


Everything seems to be working but the Server Event.  Thoughts anyone?
0
Iana Tsolova
Telerik team
answered on 25 May 2010, 04:15 PM
Hi,

In response to inanc:
The refreshGrid() method is indeed called when the RadWindow is closed. You can check the EditFormCS.aspx and EditForm.aspx.cs files code in the demo Example Source Code and Description section for more information.
And for placing the RadAjaxManager in the master page: This is the suggested approach. And in this case, you can add the ajax setting where the ajax manager updates the grid dynamically in the page/user control code behind where the grid is situated and add handler for the RadAjaxManager AjaxRequest event there as well. Find more information in the below articles:

http://www.telerik.com/help/aspnet-ajax/ajax-manager-proxy.html (last section)
http://www.telerik.com/help/aspnet-ajax/ajxaddajaxsettingsprogrammatically.html

In response to Michael:
Your code seem correct to me. However could you please specify where the javascript you are calling is placed and where is the handler for the RadAjaxManager AjaxRequest event added?

All the best,
Iana
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.
Tags
Grid
Asked by
inanc
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or