We have a radgrid which when adding or editing records, opens a separate form in a radwindow with it's own .aspx page. We have run into an issue when attempting to add a new, or edit a record from a radwindow and upon clicking the save button in the window, we cannot get the corresponding radgrid to refresh the data properly. The data saves properly in the database, the window closes, the ajax request method server side runs, and rebind method server side for the grid also runs when called from the ajax request method.
This used to work on the older RadControls back before we upgraded the site to the ASP.NET AJAX RadControls. The following sets of code are how we open the radwindow, save the data and close the radwindow, call the ajaxrequest method, and call the grid rebind method.
We open the radwindow dynamically through the itemcommand event of the radgrid as such:
This is the save button method from the window, which saves the new or existing record, and closes the window:
This is our javascript method, located in an external .js file which closes the radwindow:
After the save button event runs from the aspx page in the radwindow, it accessed the refreshGrid() javascript method on the aspx page which contains the radgrid. This is our code to get the id of the radajaxmanager to begin the Ajax Request:
The Ajax Manager we have on the same .aspx page as the radgrid has the following settings applied:
The following code is the Ajax Request run server side:
Then the rebind hits our NeedsDataSource Method and in theory should rebind the grid and refresh the data. However, after we run this process the grid does not refresh the data, unless we hit the refresh command link in the command header we created on the grid.
We have confirmed through testing that our Ajax Request event is being accessed and running the grid rebind method in the server side code. We are not receiving any javascript errors either.
On the older RadControls we had to force the postback on the page to get the AjaxManager to properly reload the grid data, which we found through the forums:
Has anyone run into this issue before with the ASP.NET AJAX controls? If so, how were you able to get the grid to refresh the data? Is it possible that the way we are opening the radwindow could cause the grid not to refresh?
We appreciate any help or suggestions.
This used to work on the older RadControls back before we upgraded the site to the ASP.NET AJAX RadControls. The following sets of code are how we open the radwindow, save the data and close the radwindow, call the ajaxrequest method, and call the grid rebind method.
We open the radwindow dynamically through the itemcommand event of the radgrid as such:
Private Sub radgPayRequest_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles radgPayRequest.ItemCommand |
If LCase(e.CommandName) = LCase("AddNewPaymentRequest") Then |
'Set the cache values to pass to the window |
Common.Cache.CacheSiteInfo.Cache_PageMode = EnumUI.PageMode.AddNew |
'Open the radwindow |
Call RadWindowSettings_AdminPilotPayRequest() |
End If |
End Sub |
Private Sub RadWindowSettings_AdminPilotPayRequest() |
Dim rwPilotPayRequest As New RadWindow |
rwPilotPayRequest.InitialBehaviors = WindowBehaviors.None |
rwPilotPayRequest.NavigateUrl = "Pilot/AdminPilotPayRequest.aspx" |
rwPilotPayRequest.Height = System.Web.UI.WebControls.Unit.Pixel(500) |
rwPilotPayRequest.Width = System.Web.UI.WebControls.Unit.Pixel(725) |
rwPilotPayRequest.VisibleStatusbar = False |
rwPilotPayRequest.Modal = False |
rwPilotPayRequest.Behaviors = WindowBehaviors.Close |
rwPilotPayRequest.DestroyOnClose = True |
rwPilotPayRequest.VisibleOnPageLoad = True |
radwWindowMan.Windows.Add(rwPilotPayRequest) |
End Sub |
This is the save button method from the window, which saves the new or existing record, and closes the window:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click |
Try |
'We run the save event here, which saves the data correctly to the database |
'Close the window |
ClientScript.RegisterStartupScript(Page.GetType](), "CloseWindow", "<script language=""javascript"">CloseRadWindow();</script>") |
End Try |
End Sub |
This is our javascript method, located in an external .js file which closes the radwindow:
function GetRadWindow() |
{ |
var oWindow = null; |
if (window.radWindow) oWindow = window.radWindow; |
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; |
return oWindow; |
} |
function CloseRadWindow() |
{ |
var oWindow = GetRadWindow(); |
oWindow.Close(); |
} |
After the save button event runs from the aspx page in the radwindow, it accessed the refreshGrid() javascript method on the aspx page which contains the radgrid. This is our code to get the id of the radajaxmanager to begin the Ajax Request:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
<script TYPE="text/javascript"> |
function refreshGrid(arg) |
{ |
if(!arg) |
{ |
$find("<%=radaManager.ClientID %>").ajaxRequest("Rebind"); |
} |
else |
{ |
$find("<%=radaManager.ClientID %>").ajaxRequest("RebindAndNavigate"); |
} |
} |
</script> |
</telerik:RadCodeBlock> |
The Ajax Manager we have on the same .aspx page as the radgrid has the following settings applied:
<telerik:RadAjaxManager ID="radaManager" RUNAT="server" OnAjaxRequest="radaManager_AjaxRequest"> |
<AjaxSettings> |
<telerik:AjaxSetting AJAXCONTROLID="radaManager"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl CONTROLID="radgPayRequest"></telerik:AjaxUpdatedControl> |
</UpdatedControls> |
</telerik:AjaxSetting> |
<telerik:AjaxSetting AJAXCONTROLID="radgPayRequest"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl CONTROLID="radgPayRequest"></telerik:AjaxUpdatedControl> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
The following code is the Ajax Request run server side:
Protected Sub radaManager_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs) Handles radaManager.AjaxRequest |
Select Case e.Argument |
Case "Rebind" |
radgPayRequest.MasterTableView.SortExpressions.Clear() |
radgPayRequest.MasterTableView.GroupByExpressions.Clear() |
radgPayRequest.MasterTableView.Rebind() |
Case "RebindAndNavigate" |
radgPayRequest.MasterTableView.SortExpressions.Clear() |
radgPayRequest.MasterTableView.GroupByExpressions.Clear() |
radgPayRequest.MasterTableView.Rebind() |
End Select |
End Sub |
Then the rebind hits our NeedsDataSource Method and in theory should rebind the grid and refresh the data. However, after we run this process the grid does not refresh the data, unless we hit the refresh command link in the command header we created on the grid.
We have confirmed through testing that our Ajax Request event is being accessed and running the grid rebind method in the server side code. We are not receiving any javascript errors either.
On the older RadControls we had to force the postback on the page to get the AjaxManager to properly reload the grid data, which we found through the forums:
Protected Overrides Sub RaisePostBackEvent(ByVal sourceControl As IPostBackEventHandler, ByVal eventArgument As String) |
MyBase.RaisePostBackEvent(sourceControl, eventArgument) |
If TypeOf sourceControl Is RadAjaxManager Then |
Select Case eventArgument |
Case "Rebind" |
radgPayRequest.MasterTableView.SortExpressions.Clear() |
radgPayRequest.MasterTableView.GroupByExpressions.Clear() |
radgPayRequest.MasterTableView.Rebind() |
Case "RebindAndNavigate" |
radgPayRequest.MasterTableView.SortExpressions.Clear() |
radgPayRequest.MasterTableView.GroupByExpressions.Clear() |
radgPayRequest.MasterTableView.Rebind() |
End Select |
End If |
End Sub 'RaisePostBackEvent |
Has anyone run into this issue before with the ASP.NET AJAX controls? If so, how were you able to get the grid to refresh the data? Is it possible that the way we are opening the radwindow could cause the grid not to refresh?
We appreciate any help or suggestions.