RadWindow newwindow = new RadWindow();
newwindow.ID =
"RadWindow2";
newwindow.NavigateUrl =
"~/ReasonForDisapproval.aspx?elementId=" + elementId + "&stateText=" + stateText + "&contentAvailability=" + contentAvailability;
newwindow.VisibleTitlebar =
true;
newwindow.Behaviors =
WindowBehaviors.Close;
newwindow.VisibleOnPageLoad = true;
//add the newly created RadWindow to the RadWindowManager
RadWindowManager1.Windows.Add(newwindow);
now in radwindow, after clicking on submit button i want to close the radwindow and refresh the grid from parent page, i am calling javascript function on submit button,
lblHeading.Text = "<script type='text/javascript'>CloseAndRebind()</" + "script>";
and my javascript function is
function
GetRadWindow()
{
var oWindow = null;
if (window.radWindow)
oWindow = window.RadWindow;
//Will work in Moz in all cases, including clasic dialog
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
//IE (and Moz as well)
return oWindow;
}
function CloseAndRebind()
{
GetRadWindow().BrowserWindow.refreshGrid(
null);
GetRadWindow().Close();
}
But its not closing radwindow and also not refreshing grid, its giving javascript error "object doesnt support this property or methods"
Earlier reply will be appreciated.
Thanks in advance
Suvarna
11 Answers, 1 is accepted
Have you defined the refreshGrid() method on the parent page? If not, probably this should be the reason for the error. Here's an example for the same approach:
The refreshGrid method should be defined on the main(parent) page, which will in turn fire an ajax request:
js(aspx):
function refreshGrid(arg) |
{ |
if(!arg) |
{ |
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); |
} |
} |
Rebind the grid after clearing the sort and group expressions in the AjaxRequest server side event:
c#(aspx.cs):
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
if (e.Argument == "Rebind") |
{ |
RadGrid1.MasterTableView.SortExpressions.Clear(); |
RadGrid1.MasterTableView.GroupByExpressions.Clear(); |
RadGrid1.Rebind(); |
} |
} |
Hope this helps..
Princy.
Thanks for the quick reply, I am new to telerik controls, First time i am using radajaxmanager. In the reply you told about adding refreshGrid() function, but who will exactly call this function, I have added RadAjaxManager as follows
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="AccessoryGrid">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="AccessoryGrid" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
and added the function as you told. Is there anything needed in this? Please give more details.
Thanks,
Suvarna
Here is the code that I tried for similar scenario.
ParentPage:
ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="AccessoryGrid" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
JavaScript:
function refreshGrid(arg) |
{ |
if(!arg) |
{ |
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); // Invoking ajaxRequest |
} |
} |
CS:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
if (e.Argument == "Rebind") |
{ |
RadGrid1.MasterTableView.SortExpressions.Clear(); |
RadGrid1.MasterTableView.GroupByExpressions.Clear(); |
RadGrid1.Rebind(); |
} |
} |
Page in RadWindow:
JavaScript:
function CloseAndRebind(args) |
{ |
GetRadWindow().Close(); |
GetRadWindow().BrowserWindow.refreshGrid(args); |
} |
You can refer the following demo for more information: Window Editing
Hope this helps,
Shinu.
Anytime I try to run the line:
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); |
I get the error:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
I know that I can change the line to read:
$find("<%# RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); |
to resolve the error (note change from <%= to <%#) but I still always get an error 'null' is null or not an object when it tries to find my control. I'm assuming it's relating to master pages on my sites. I can get a handle on the control using $get method but then I get the error Object doesn't support this property or method when trying to call methods as shown in multiple examples on your site..
Do you have any suggestions for the best way to get a handle on the controls when they're inside of master pages?? This drives me nuts!
Thanks!
Simply wrap your JS code around RadScriptBlock. For more details please visit: http://www.telerik.com/help/aspnet-ajax/ajxradscriptblockradcodeblock.html
Greetings,
Nikolay
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.
I open a second radwindow from the first with a javascript function using the radwindow manager at the browser level window.
function openAddFollowUpWindow() { |
//open a new window for adding a client FollowUp parsing the URL request for the current client ID |
var oManager = GetRadWindow().GetWindowManager(); |
var oWnd = oManager.Open("FollowUpPopup.aspx", "RadWindow1"); // |
//var oWnd = radopen("FollowUpPopup.aspx", "Add FollowUp"); |
oWnd.set_modal(true); |
oWnd.setSize(800, 500); |
oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Reload); |
oWnd.set_visibleStatusbar(false); |
oWnd.Center(); |
} |
In the case of closing a radwindow and updating the grid on the parent browser level page I would place something like this javascript on the parent page.
function refreshRecentHotlineCallsGrid() { |
var radMgr = $find("<%=RadAjaxManager1.ClientID %>"); |
radMgr.ajaxRequest("Rebind_RecentHotlineCalls"); |
} |
then call it using some code behind in the child window:
//call the client side CloseAndRebind on reload of page after postback which calls the parent refresh grid |
ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true); |
coupled with a javascript function in the child window:
function GetRadWindow() |
{ |
var oWindow = null; |
if (window.radWindow) oWindow = window.radWindow; |
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; |
return oWindow; |
} |
function CloseAndRebind(args) |
{ |
GetRadWindow().BrowserWindow.refreshRecentHotlineCallsGrid(args); |
GetRadWindow().Close(); |
} |
so how would I make the call to the other radwindow rather than the parent window?
In the other radwindow I have the javacript code:
function refreshFollowUpsGrid() { |
var radMgr = $find("<%=RadAjaxManager1.ClientID %>"); |
radMgr.ajaxRequest("Rebind_FollowUps"); |
} |
Cheers
Jonathan
If I understand your scenario correctly you are looking for functionality similar to what is demonstrated on the demo bellow:
http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx
Regards,
Nikolay
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.
Actually the code for the communication between Dialog1 and Dialog2 is listed - you can choose both aspx and cs code the code viewer in the example.
In Dialog2.aspx you can see that when button Ok is pressed returnValue get called and selected city is transferred to Dialog1.aspx by calling:
....
// Get a reference to the first RadWindow's content
var
contentWin = dialog1.get_contentFrame().contentWindow
//Call the predefined function in Dialog1
contentWin.populateCityName(selectedCapital);
....
All the best,
Nikolay
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.
please help
Please check the following demo:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid
All the best,
Nikolay
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.