I have a main page with a radgrid. Double clicking the grid opens up a radwindow that lets the users edit the grid row data. I want the grid on the parent page to refresh without having to do a full page refresh. I tried the Ajax call. Everything seem to work as expected. But the grid does not seem to refresh. I can debug the code and see that the server side code does fireup and the grid rebinds successfully. It just does not show up on screen. Here is my code.
On the main page, I have the AJAX manager as below.
<
telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="grdAdminList" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
Here is the server side code:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
if (e.Argument == "Rebind")
{
grdAdminList.Rebind();
}
This function calls the actual refreshGrid function that is on the main page.
function
refreshGrid()
{
GetRadWindow().BrowserWindow.refreshGrid();
}
Main page function:
function refreshGrid()
{
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
}
Thanks!
vithiya
43 Answers, 1 is accepted
Go through the following help articles.
Exclude controls from ajaxifying
Forcing postback
Frequently Asked Questions
Shinu.
Thank you for the quick response. But I am not sure how the links you provided are related to what I am trying to accomplish. I do not have an ajaxpanel in my app. I only have ajaxmanager. The code behind is working as expected and the ajax request is being processed as well. When I debug the code, I can see it stepping through the ajax request and rebinding the grind which then has the updated data. It's the grid on the screen that does not show the updated data. To me it looks like the client side is missing something. Please look at my code that I posted earlier and confirm that at least I am going in the right direction.
Thanks!
vithiya
Thanks a lot!
vithiya
Thanks!
vithiya
I am now trying to move the AjaxManager control to the master page and manage ajax calls on the content page using the AjaxManagerProxy control.
After doing so, when I try to initiate the ajaxrequest call using javascript, it does not seem to find the ajaxmanager at all. Here is the code to make the ajaxrequest call.
var
radMgr = $find("<%= RadAjaxManagerMaster.ClientID %>"); (did not work)
radMgr.ajaxRequest(
"Rebind");
Also tried,
var radMgr = $find("<%= RadAjaxManagerProxy.ClientID %>"); (did not work)
radMgr.ajaxRequest(
"Rebind");
And finally tried,
var radMgr = $find("<%= RadAjaxManagerMaster.GetCurrent(Page).ClientID %>"); (did not work)
radMgr.ajaxRequest(
"Rebind");
All of the above did not work. In the first and the last case, it kept saying that the control did not exist in the context. The second option did not give me any error message, but did not work either.
Please let me know how I can get it to work.
Thank you!
vithiya
I think that the following online demo:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Controls/Examples/Integration/GridAndWindow/DefaultCS.aspx?product=grid
and the demo project from the relevant KB article on our site:
http://www.telerik.com/support/kb/article/b454K-gmb-b454T-cba-b454c-cba.aspx
can become the basis for your implementation. Additionally, how to reference the ajax manager in master/content page scenario and trigger ajax requests from the client you can learn from the resources pointed below:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Ajax/Examples/Manager/MasterPage/DefaultCS.aspx
http://www.telerik.com/help/aspnet-ajax/ajxmasterpageupdateeverywhere.html
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
When I use the below code, I get a null exception (System.NullReferenceException: Object reference not set to an instance of an object.). I am trying to ajaxify a radgrid in the content page using the proxy.
var
radMgr = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
radMgr.ajaxRequest;
Please advice!
Thank you!
vithiya
Does using a bit different syntax, namely:
C#
radMgr = $find("<%= RadAjaxManager.GetCurrent(this).ClientID %>");
or
VB.NET
radMgr = $find("<%= RadAjaxManager.GetCurrent(Me).ClientID %>");
makes a difference? This is indeed an odd issue you come upon and the best means to progress in our investigation is to put together a working subset of your project and send it attached to a formal support ticket. We will examine it in detail and will advice you further.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The best overloaded method match for 'Telerik.Web.UI.RadAjaxManager.GetCurrent(System.Web.UI.Page)' has some invalid arguments
I have a standard web page with the radscript manager and radajax manager.
I have a user control based on the rad grid editing demo. instead of the ajax manager I am using the manager proxy in my user control
this is the sample code i used to base my user control
http://demos.telerik.com/aspnet/prometheus/Controls/Examples/Integration/GridAndWindow/DefaultCS.aspx?product=grid
Any help will be appreciated
Regards
Chris
Try modifying the line in your code that throws the exception as below:
| Telerik.Web.UI.RadAjaxManager.GetCurrent(this.Page) |
instead of trying to get manager instance as you did:
| Telerik.Web.UI.RadAjaxManager.GetCurrent(System.Web.UI.Page) |
Let me know if this helps.
Regards,
Iana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
<telerik:AjaxSetting AjaxControlID="RadAjaxManagerModifyProtocol">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGridPIManager" />
</UpdatedControls>
</telerik:AjaxSetting>
and my complete code is below.
Page1.aspx:
<!-- Footer Section -- In this footer user control i placed RadScriptManager which i used it in every page along
with some footer text-->
<tcn:footer ID="footer" runat="server" />
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| //<![CDATA[ |
| function openRadWindow(protocol_id) |
| { |
| var oWnd = radopen("../popups/associateUser.aspx?id=" + user_id , "radwindow1") |
| oWnd.center(); |
| } |
| function refreshGrid(arg) |
| { |
| if (arg = "Rebind"){ |
| $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); |
| } |
| } |
| //]]> |
| </script> |
| </telerik:RadCodeBlock> |
<telerik:RadWindowManager ShowContentDuringLoad="false" VisibleTitlebar="true" Modal="true" RestrictionZoneID="divMainBody" VisibleStatusbar="true" AutoSize="false" Skin="Black" ID="RadWindowManager1" Width="600px" Height="600px" runat="server">
</telerik:RadWindowManager>
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" > | |
| <AjaxSettings> | |
| <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> | |
| <UpdatedControls> | |
| <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> | |
| </UpdatedControls> | |
| </telerik:AjaxSetting> | |
| <telerik:AjaxSetting AjaxControlID="RadGrid1"> | |
| <UpdatedControls> | |
| <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> | |
| </UpdatedControls> | |
| </telerik:AjaxSetting> | |
</AjaxSettings>
|
Page1.aspx.vb (codebehind):
| Private Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource |
| //My own function with returns the dataset which assign |
| //to the RadGrid1.DataSource and No Databind() in this function. |
| UserManagerBindData() |
| End Sub |
| Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest |
| RadGrid1.MasterTableView.SortExpressions.Clear() |
| RadGrid1.MasterTableView.GroupByExpressions.Clear() |
| RadGrid1.Rebind() |
| End Sub |
associateUser.aspx.vb (Popup-Codebehind):
This popup contains a RadGrid2 with checkbox column and a Add User Button.
In the button click event iam inserting the selected user record in the grid directly to the database.
after succesffully inserted into database. I added the following code.
| Response.Write("<script language='javascript'>var oWindow = null; if (window.radWindow) oWindow = window.radWindow; else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; oWindow.close(); oWindow.BrowserWindow.refreshGrid('Rebind');</script>") |
Please note: Make sure the order of placing the RadManagers like The Script Manager followed by Ajax Manager as mentioned in the above code (Page1.aspx)
Hope it helps some one like me..
Thank you.
I did not know that I needed to authorize the events coming from the RadAjaxManager1to also update the grid. That did the trick for me and it seems logical.
EnableViewState="false" should not be an option here to solve the problem...
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager>I don't want to set enableviewstate="false" unless I have to. Is there another way around this? I am providing my code below.
ASPX:
<script type="text/javascript"> function onRequestStart(sender, args) { if (args.get_eventTarget().indexOf("excelExport") >= 0) { args.set_enableAjax(false); } } function ShowInsertForm() { var combo = $find("<%= RadComboBox1.ClientID %>"); var comboItem = combo.get_selectedItem(); if (!comboItem) { window.radopen("AddComment.aspx", "UserListDialog"); } else { window.radopen("AddComment.aspx?PO=" + comboItem.get_value("PO"), "UserListDialog"); } return false; } function refreshGrid() { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); } </script> <telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server" Skin="WebBlue"> </telerik:RadFormDecorator> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" > <ClientEvents OnRequestStart="onRequestStart" /> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadComboBox1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" UpdatePanelHeight="100%"/> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" UpdatePanelHeight="100%" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadFilter1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadFilter1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <asp:Table runat="server" ID="table1" Width="873px"> <asp:TableHeaderRow CssClass="style1"> <asp:TableHeaderCell ColumnSpan="2">Grant Communications - Admin</asp:TableHeaderCell> </asp:TableHeaderRow> <asp:TableRow> <asp:TableCell CssClass="style1"> <telerik:RadComboBox ID="RadComboBox1" Runat="server" Skin="WebBlue" Width="373px" AutoPostBack="true" EnableLoadOnDemand="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged" MaxHeight="350px" Text="Select a Grant" EmptyMessage="Select a Grant"> </telerik:RadComboBox> </asp:TableCell> <asp:TableCell CssClass="style1"> <asp:Label runat="server" ID="lblResult"></asp:Label> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell CssClass="style1" ColumnSpan="2"> <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" GridLines="None" Skin="WebBlue" OnNeedDataSource="RadGrid1_NeedDataSource" OnDataBound="RadGrid1_DataBound" width="873px" AutoGenerateColumns="False"> <ExportSettings ExportOnlyData="True" IgnorePaging="true" OpenInNewWindow="true"> <Excel Format="ExcelML" /> </ExportSettings> <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True"> </ClientSettings> <MasterTableView CommandItemDisplay="Top" > <CommandItemSettings > </CommandItemSettings> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="Muni_Name" HeaderText="Grantee" UniqueName="column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="PO" HeaderText="PO" UniqueName="column1"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CommentDate" FilterControlWidth="30px" HeaderText="Comment Date" UniqueName="column2"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Commentor" HeaderText="Commentor" UniqueName="column3"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Comment" HeaderText="Comment" UniqueName="column4"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="InsertDate" FilterControlWidth="30px" HeaderText="Insert Date" UniqueName="column5"> </telerik:GridBoundColumn> </Columns> <CommandItemTemplate> <a href="#" onclick="return ShowInsertForm();">Add New Record</a> <asp:ImageButton ID="excelExport" runat="server" ImageUrl="~/images/ExportToExcel.gif" CommandName="ExportToExcel" /> </CommandItemTemplate> </MasterTableView> </telerik:RadGrid> </asp:TableCell> </asp:TableRow> </asp:Table> <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" Skin="WebBlue"> <Windows> <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Width="370px" Height="350px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" /> </Windows> </telerik:RadWindowManager>VB:
Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest If e.Argument = "Rebind" Then RadGrid1.MasterTableView.SortExpressions.Clear() RadGrid1.MasterTableView.GroupByExpressions.Clear() RadGrid1.Rebind() End If End SubProtected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource connSql.ConnectionString = sqlConn.ToString() Dim poSqlCom As New SqlCommand("dbo.getRAComment", connSql) poSqlCom.CommandType = CommandType.StoredProcedure poSqlCom.Parameters.AddWithValue("@User", "Admin") poSqlCom.Parameters.AddWithValue("@PO", RadComboBox1.SelectedValue.ToString()) Dim adapter As New SqlDataAdapter(poSqlCom) Dim links As New DataTable() Try adapter.Fill(links) Catch ex As Exception lblResult.Text = ex.Message If connSql.State = ConnectionState.Open Then connSql.Close() End If End Try RadGrid1.DataSource = links End Sub Protected Sub RadGrid1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.DataBound If connSql.State = ConnectionState.Open Then connSql.Close() End If End Sub 'RadGrid1_DataBoundI appreciate any help on this that I can get!
I guess that you expect the grid to refresh after you add a comment with your popup form and close it?
Because I don't see what is calling the javascript refreshGrid method.
this is probably obvious for you, but just in case, you have to close your popup like that:
protected void btnClose_Click(object sender, EventArgs e){ //ScriptManager Enables AJAX In Your Web Apps ScriptManager.RegisterStartupScript(Page, Page.GetType(), "mykey", "CloseAndRebind();", true);}which will call the folowing popup javascript:
<script type="text/javascript"> //reload the parent function CloseAndRebind(args) { GetRadWindow().Close(); GetRadWindow().BrowserWindow.refreshGrid(args); } function GetRadWindow() { var oWindow = null; if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including classic dialog else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well) return oWindow; }This is the part that will call the refreshgrid...
and last maybe that you are using Page.ClientScript.RegisterStartupScript instead of ScriptManager.RegisterStartupScript or vice versa...
If you are already doing all this, please, post a 'working' sample so that somebody can check after you code...
Kind regards,
John.
Yes. I want the grid to refresh after I have added a new record. When I put a break at the databind (after the record is added), I can see the added data in the radgrid.mastertablebview items.
I typed: ? radgrid1.MasterTableView.Items(2).Cells(6).Text into the immediate window (in Visual Studio), and got this result: "87456".
? radgrid1.MasterTableView.Items(2).Cells(4).Text
"1/27/2011 12:00:00 AM"
The grid is just not refreshing on the screen. I don't know how else to explain it.
I do have a addrecord.aspx page that has all the code you mentioned. I did change from clientscript.registerstartupscript to scripmanager.registerstartupscript, but that didn't make a difference.
Here's the code I have for that page:
<form id="form1" runat="server"> <script type="text/javascript"> function CloseAndRebind() { GetRadWindow().BrowserWindow.refreshGrid(); GetRadWindow().close(); } 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 CancelEdit() { GetRadWindow().close(); } </script> <div id="art-page-background-gradient"> <asp:Table ID="Table1" runat="server" Height="200px"> <asp:TableRow ID="tr1"> <asp:TableCell ColumnSpan="2"> <asp:Label ID="lblNone" runat="server"></asp:Label> </asp:TableCell> </asp:TableRow> <asp:TableRow ID="tr2"> <asp:TableCell> <asp:Label ID="Label1" runat="server" Text="Comment Date"></asp:Label> </asp:TableCell> <asp:TableCell> <telerik:RadDatePicker ID="cmDate" Runat="server" DateInput-EmptyMessage="Select a Date" Skin="WebBlue" > </telerik:RadDatePicker> <asp:RequiredFieldValidator ID="PickerRequiredFieldValidator" runat="server" Display="Dynamic" ControlToValidate="cmDate" ErrorMessage="Please select a date" ForeColor="Black" Font-Bold="True" Font-Italic="True" /> </asp:TableCell> </asp:TableRow> <asp:TableRow ID="tr3"> <asp:TableCell> <asp:Label ID="Label2" runat="server" Text="Comment"></asp:Label><br /> <asp:RequiredFieldValidator ID="TextBoxRequiredFieldValidator" runat="server" Display="Dynamic" ControlToValidate="txtComment" ErrorMessage="Must Enter Comment" ForeColor="Black" Font-Bold="True" Font-Italic="True" /> </asp:TableCell> <asp:TableCell> <telerik:RadTextBox ID="txtComment" TextMode="MultiLine" Runat="server" EmptyMessage="Type your comment" Rows="5"> </telerik:RadTextBox> </asp:TableCell> </asp:TableRow> <asp:TableRow ID="tr4"> <asp:TableCell ColumnSpan="2"> <asp:Button ID="Button1" runat="server" Text="Add Comment" /> <asp:Button ID="Button2" runat="server" Text="Cancel" CausesValidation="false" /> </asp:TableCell> </asp:TableRow> </asp:Table> <telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server" Skin="WebBlue" /> <telerik:RadScriptManager ID="RadScriptManager1" Runat="server"> </telerik:RadScriptManager> </div> </form>
'VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Sets up page Me.Page.Title = "Add Comment" If (Not Page.IsPostBack) Then cmDate.SelectedDate = DateTime.Today End If End Sub Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init 'Finishes setting up page. If the PO is not pushed through, then an error message will appear on the page. If PO exists, then the PO will appear on the page. If Request.QueryString("PO") Is Nothing Then lblNone.Text = "No PO Select. Please select a PO in then click on the add new record." tr2.Visible = False tr3.Visible = False Button1.Visible = False Button2.Text = "Ok" Else lblNone.Text = Request.QueryString("PO") End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Try 'Adds Comment to table connSql.ConnectionString = sqlConn.ToString() Dim exSqlCom As New SqlCommand("dbo.AddComment", connSql) exSqlCom.CommandType = CommandType.StoredProcedure exSqlCom.Parameters.AddWithValue("@PO", lblNone.Text) exSqlCom.Parameters.AddWithValue("@Commentor", "GP") exSqlCom.Parameters.AddWithValue("@CommentDate", cmDate.SelectedDate) exSqlCom.Parameters.AddWithValue("@Comment", txtComment.Text) exSqlCom.Parameters.Add("@ReturnValue", SqlDbType.Int) exSqlCom.Parameters("@ReturnValue").Direction = ParameterDirection.Output connSql.Open() exSqlCom.ExecuteNonQuery() connSql.Close() 'Calls for grid rebind and closes this page. ScriptManager.RegisterStartupScript(Page, Page.GetType(), "mykey", "CloseAndRebind();", True) Catch ex As Exception lblNone.Text = ex.Message If connSql.State = ConnectionState.Open Then connSql.Close() End If End Try End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click 'Closes the page, and cancels the update. ScriptManager.RegisterStartupScript(Page, Page.GetType(), "mykey", "CancelEdit();", True) 'ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", True) End SubThe ScriptManager.RegisterStartupScript thing did the trick for me. My problem was that the ajax event on the page was not triggered.
Can you confirm that your code goes trough the RadAjaxManager1_AjaxRequest after you close the page and that the rebind is called?
After that I would try to get your grid out of the table structure you have here just to make sure it does not interfere.
Also does the grid refresh after you click on a refresh command button you could add on the grid?
Does the grid refresh after you trigger a new postback on the grid page?
It looks like everything works fine just the grid does not seem to understand it should load the data it gets back.
Then last I would try to remove the ajaxmanager from the page to see if things are working when not ajaxified?
Can't you put a small project together and hand it over so I can try it on my side?
Thanks for all your great questions. It really pointed me into the right directions. I tried pulling the grid out of the table, but that didn't seem to work. Then I wondered, is it because it's on a masterpage? I created a new page without a master, and copied all my controls and code to the new page. Worked like a charm.
I guess I have to do the ajax manager/ajax proxy thing. I was hoping to avoid that because I only need the ajaxmanager for the page itself. No other content areas need the ajax manager.
I'll let you know what gets the code to work.
Thank you again for the guidance!
GP
Ok, so I got it to work. It did have something to do with master/content pages. The problem is, I have two content areas that both use the telerik script manager. I had to put that out on the Master page to prevent errors. The AjaxManager was hiccuping because it couldn't find that script manager. I had to put the AjaxManager on the MasterPage, and put a ajaxmanagerproxy to the content page.
My new issue is that my stylesheet is dropping for some reason. I'll get that working. However, that is not as relevant to this part of the discussion. Here's the code to make the master/content ajaxmanager happy:
MasterPage.aspx
- just make sure your AjaxManager is loaded before the content, or else you will throw a null exception when the content script tries to find the Master's AjaxManager<body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" Runat="server" /> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" />CommentReport.aspx
<asp:Content ID="Content5" ContentPlaceHolderID="SheetContentPlaceHolder" runat="server"><telerik:RadCodeBlock ID="rcb1" runat="server"> <script type="text/javascript"> function onRequestStart(sender, args) { if (args.get_eventTarget().indexOf("excelExport") >= 0) { args.set_enableAjax(false); } } function ShowInsertForm() { var combo = $find("<%= RadComboBox1.ClientID %>"); var comboItem = combo.get_selectedItem(); if (!comboItem) { window.radopen("AddComment.aspx", "UserListDialog"); } else { window.radopen("AddComment.aspx?PO=" + comboItem.get_value("PO"), "UserListDialog"); } return false; } function refreshGrid() { $find("<%= RadAjaxManager.GetCurrent(me).ClientID %>").ajaxRequest("Rebind"); } </script> </telerik:RadCodeBlock> <telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server" Skin="WebBlue"> </telerik:RadFormDecorator> <telerik:RadAjaxManagerProxy ID="RAMP1" runat="server" > <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManagerProxy> <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True"
AllowPaging="True" AllowSorting="True" GridLines="None" Skin="WebBlue" OnNeedDataSource="RadGrid1_NeedDataSource" OnDataBound="RadGrid1_DataBound" width="873px" AutoGenerateColumns="False"> <ExportSettings ExportOnlyData="True" IgnorePaging="true" OpenInNewWindow="true"> <Excel Format="ExcelML" /> </ExportSettings> <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True"> </ClientSettings> <MasterTableView CommandItemDisplay="Top" > <CommandItemSettings > </CommandItemSettings> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="Muni_Name" HeaderText="Grantee" UniqueName="column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="PO" HeaderText="PO" UniqueName="column1"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CommentDate" FilterControlWidth="30px" HeaderText="Comment Date" UniqueName="column2"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Commentor" HeaderText="Commentor" UniqueName="column3"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Comment" HeaderText="Comment" UniqueName="column4"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="InsertDate" FilterControlWidth="30px" HeaderText="Insert Date" UniqueName="column5"> </telerik:GridBoundColumn> </Columns> <CommandItemTemplate> <a href="#" onclick="return ShowInsertForm();">Add New Record</a> <asp:ImageButton ID="excelExport" runat="server" ImageUrl="~/images/ExportToExcel.gif" CommandName="ExportToExcel" ImageAlign="Right" AlternateText="Export To Excel" /> </CommandItemTemplate> </MasterTableView> </telerik:RadGrid> <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" Skin="WebBlue"> <Windows> <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Width="370px" Height="350px"ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" /> </Windows> </telerik:RadWindowManager></asp:Content>CommentReport.aspx - Just the part that will help with the example:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then BindToDataTable(RadComboBox1) End If Dim manager As RadAjaxManager = RadAjaxManager.GetCurrent(Page) manager.ClientEvents.OnRequestStart = "onRequestStart" AddHandler manager.AjaxRequest, AddressOf manager_AjaxRequestEnd Sub'Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)' If e.Argument = "Rebind" Then' RadGrid1.MasterTableView.SortExpressions.Clear()' RadGrid1.MasterTableView.GroupByExpressions.Clear()' RadGrid1.Rebind()' End If'End SubProtected Sub manager_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) 'handle the manager AjaxRequest event here If e.Argument = "Rebind" Then RadGrid1.MasterTableView.SortExpressions.Clear() RadGrid1.MasterTableView.GroupByExpressions.Clear() RadGrid1.Rebind() End IfEnd SubAddComment.aspx (Window Page) Just the parts relevant to discussion
<form id="form1" runat="server"> <script type="text/javascript"> function CloseAndRebind() { GetRadWindow().BrowserWindow.refreshGrid(); GetRadWindow().close(); } 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 CancelEdit() { GetRadWindow().close(); } </script>AddComment.vb (Just relevant parts)
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "mykey", "CloseAndRebind();", True)'or if you want to cancel the insertScriptManager.RegisterStartupScript(Page, Page.GetType(), "mykey", "CancelEdit();", True)
Just to say, I also have a master page but do not use the proxy thing and it is working just fine.
I did paste you code directly extracted from my working project.
Anywa, at least by using the proxy manager you get javascript intelissense which I don't get without...
Good luck with your project GP,
John.
Anyway, Thank you again for your help.
Have a great weekend!
GP
Sometimes I got into trouble and I'm happy to find someone just listening to my problems...
So, no, the (rad)scriptmanager is in the main page.
Here is how my controls are laid out.
The master page:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Proxi.SiteMaster" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"><head runat="server"> <title></title> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" /> <link href="~/Styles/qsf.css?t=<%= DateTime.Now.Ticks %>" rel="stylesheet" type="text/css" /> <link href="~/Styles/Site.css?t=<%= DateTime.Now.Ticks %>" rel="stylesheet" type="text/css" /> <link href="~/Styles/Styles.css?t=<%= DateTime.Now.Ticks %>" rel="stylesheet" type="text/css" /> <link rel="Shortcut Icon" href="favicon.ico" type="image/x-icon" /> <style type="text/css"> </style></head><body class="BODY"> <form id="mainForm" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" AsyncPostBackErrorMessage="Une erreur est survenue."> <Scripts> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> </Scripts> </telerik:RadScriptManager> <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Windows7" /> <script type="text/javascript"> </script> <asp:ContentPlaceHolder ID="HeadContent" runat="server"> </asp:ContentPlaceHolder> <asp:ContentPlaceHolder ID="MainContent" runat="server" /> </form></body></html>The page:
<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Sessions.aspx.cs" Inherits="Proxi.Sessions" %><asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> //open child window to edit new record//the JS... //refresh current session grid function refreshGrid(arg) { if (!arg) { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); } else { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate"); } } }); </script> </telerik:RadCodeBlock> <telerik:RadAjaxManager ID="RadAjaxManager1" OnAjaxRequestError="AjaxRequestErrorHandler" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" Height="500px" AllowPaging="True" AllowSorting="True" PageSize="20" OnDeleteCommand="RadGrid1_DeleteCommand" OnUnload="RadGrid1_Unload" AutoGenerateColumns="False" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated" OnItemCommand="RadGrid1_ItemCommand" GridLines="None" Culture="fr" OnPreRender="RadGrid1_PreRender"> <PagerStyle Mode="NextPrevAndNumeric" /> <MasterTableView InsertItemPageIndexAction="ShowItemOnCurrentPage" DataKeyNames="SessionID"etc...The popup looks like yours... I emoved the js code. It's the same then yours...
Spot any difference?
John.
OnAjaxRequest="RadAjaxManager1_AjaxRequest" in your main tag.I switched to that, and it seems to work, but the grid sort of "blinks" for a second. It disappears and reappears. When I use the proxy, the grid updates without a blink, and then area behind it blinks as if it's reloading other bits.
Regardless, folks, you now have a bunch of ways to reach the same goal.
Whew...
You'll have a better weekend now, hopefully :)
i have problem with radajaxmanager,i have 2 radgrids in my page,while i am clicking the first radgrid itemcommand event ,i need to bind second radgrid ,i am using radajaxmanager,because of this i am unable to bind data to the second radgrid.when i removed radajaxmanager i am able to bind,but i need that radajaxmanager to open radwindow.i did my binding to first radgrid with the example of "http://demos.telerik.com/aspnet-ajax/controls/examples/integration/grwindow/defauidandltcs.aspx?product=window".please give me some idea.
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"><ClientEvents OnRequestStart="onRequestStart" /> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> <telerik:AjaxUpdatedControl ControlID="RadGrid2" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager>http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectedvalue/defaultcs.aspx
Also bear in mind that window editing is supported directly with popup edit form:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/popupeditform/defaultcs.aspx
Kiara
Thank u for reply,
Here is my asp code,when i clicked on the 1st grid event,2nd grid was binding successfully.but when i clicking on th
e "Add New Activity"(anchore tag of 'command item template' on below code)was not showing pop up.<%@ Page Language="C#" MasterPageFile="~/Member/MemberMaster.Master" AutoEventWireup="true" CodeBehind="MyActivity.aspx.cs" Inherits="Virtu.WebUI.MyActivity" %><%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td width="70%" align="left" valign="top" style="padding-top: 8px; padding-left: 10px;"> <table width="100%" height="70%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="12" height="33" align="left" valign="top" background="../Images/box-img2.gif" bgcolor="#FFFFFF"> <img src="../Images/box-img1.gif" width="12" height="36" /> </td> <td width="100%" align="center" valign="top" background="../images/box-img2.gif" class="heading-orange" style="padding-top: 6px;"> All Activities List </td> <td width="12" align="right" valign="top" background="../Images/box-img2.gif" bgcolor="#FFFFFF"> <img src="../Images/box-img3.gif" width="12" height="36" /> </td> </tr> <tr> <td align="left" valign="top" colspan="3" width="100%"> <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("ActivityEntry.aspx?ActivityID=" + id, "UserListDialog"); return false; } function ShowInsertForm() { debugger; var groupid = '<%=Request.QueryString["GroupID"].ToString()%>'; window.radopen("ActivityEntry.aspx?GroupID=" + groupid, "UserListDialog"); return false; } function refreshGrid(arg) { if (!arg) { $find("< % = RadAjaxManager1.ClientID % >").ajaxRequest("Rebind"); } else { $find("< % = RadAjaxManager1.ClientID % >").ajaxRequest("RebindAndNavigate"); } } </script> </telerik:RadCodeBlock> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> <clientevents onrequeststart="onRequestStart" /> <ajaxsettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> <telerik:AjaxUpdatedControl ControlID="RadGrid2" /> </UpdatedControls> </telerik:AjaxSetting> </ajaxsettings> </telerik:RadAjaxManager> <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Vista" AllowPaging="True" Width="97%" ShowHeader="false" ondeletecommand="RadGrid1_DeleteCommand" onitemcommand="RadGrid1_ArchiveCommand" onitemcreated="RadGrid1_ItemCreated" onneeddatasource="RadGrid1_NeedDataSource"> <pagerstyle mode="NumericPages" /> <mastertableview autogeneratecolumns="False" datakeynames="ActivityID" width="100%" commanditemdisplay="Top" pagesize="5"> <Columns> <telerik:GridBoundColumn DataField="ActivityID" ReadOnly="True" SortExpression="ActivityID" UniqueName="ActivityID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ActivityName" SortExpression="ActivityName" UniqueName="ActivityName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ActivityDescription" SortExpression="ActivityDescription" UniqueName="ActivityDescription"> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn DataField="StartDate" UniqueName="StartDate" SortExpression="StartDate" HeaderStyle-Width="110px" DataFormatString="{0:d}" /> <telerik:GridDateTimeColumn DataField="EndDate" UniqueName="EndDate" SortExpression="EndDate" HeaderStyle-Width="110px" DataFormatString="{0:d}" /> <telerik:GridTemplateColumn UniqueName="TemplateEditColumn"> <ItemTemplate> <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridButtonColumn CommandName="Archive" Text="Archive" ConfirmDialogType="RadWindow" ConfirmText="Do you want to archieve the Activity" UniqueName="ActivityID"> </telerik:GridButtonColumn> <telerik:GridButtonColumn CommandName="Delete" Text="Delete" ConfirmDialogType="RadWindow" ConfirmText="Do you want to delete the Activity" UniqueName="CategoryID" > </telerik:GridButtonColumn> <telerik:GridButtonColumn CommandName="Event" Text="Events" UniqueName="Eventclm"> </telerik:GridButtonColumn> </Columns> <CommandItemTemplate > <a href="#" onclick="return ShowInsertForm();">Add New Activity</a> </CommandItemTemplate> </mastertableview> <clientsettings> <Selecting AllowRowSelect="true" /> </clientsettings> </telerik:RadGrid> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="12" height="33" align="left" valign="top" background="../Images/box-img2.gif" bgcolor="#FFFFFF"> <img src="../Images/box-img1.gif" width="12" height="36" /> </td> <td width="100%" align="center" valign="middle" background="../images/box-img2.gif" class="heading-orange"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="20"> </td> <td align="center" class="heading-orange" style="white-space: nowrap;" valign="middle"> <span id="spanBlogFamilyName" runat="server">My Events</span> </td> </tr> </table> </td> <td width="12" align="right" valign="top" background="../Images/box-img2.gif" bgcolor="#FFFFFF"> <img src="../Images/box-img3.gif" width="12" height="36" /> </td> </tr> <tr> <td align="left" valign="top" colspan="3" width="100%"> <telerik:RadGrid AutoGenerateColumns="true" ShowHeader="false" OnItemCreated="RadGrid2_ItemCreated" ID="RadGrid2" runat="server" Skin="Vista" AllowPaging="True" Width="97%" Height="200px" EnableAjaxSkinRendering="true"> <pagerstyle mode="NumericPages" /> <mastertableview autogeneratecolumns="False" datakeynames="EventID" width="100%" commanditemdisplay="Top" pagesize="5"> <Columns> <telerik:GridBoundColumn DataField="EventID" ReadOnly="True" SortExpression="EventID" UniqueName="EventID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="EventName" SortExpression="EventName" UniqueName="EventName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="EventDescription" SortExpression="EventDescription" UniqueName="EventDescription"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="EventFees" SortExpression="EventFees" UniqueName="EventFees"> </telerik:GridBoundColumn> <telerik:GridButtonColumn CommandName="Archive" Text="Archive" ConfirmDialogType="RadWindow" ConfirmText="Do you want to archieve the Activity" UniqueName="eventarchive"> </telerik:GridButtonColumn> <telerik:GridButtonColumn CommandName="Deleteevent" Text="Delete" ConfirmDialogType="RadWindow" ConfirmText="Do you want to delete the Activity" UniqueName="eventDelete"> </telerik:GridButtonColumn> <telerik:GridTemplateColumn UniqueName="evenTemplateEditColumn"> <ItemTemplate> <asp:HyperLink ID="EditLinks" runat="server" Text="Edit"></asp:HyperLink> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> <CommandItemTemplate> <a href="#" onclick="return ShowInsertForm();" >Add New Event</a> </CommandItemTemplate> </mastertableview> <clientsettings> <Selecting AllowRowSelect="true" /> </clientsettings> </telerik:RadGrid> </td> </tr> </table> <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Vista"> <windows> <telerik:RadWindow Skin="Vista" ID="UserListDialog" runat="server" Title="User List Dialog" Height="400px" Width="600px" Left="150px" ReloadOnShow="true" Modal="true" /> </windows> </telerik:RadWindowManager> <asp:Panel ID="pnlMyGroupMessage" runat="server" Width="100%" Height="125px" CssClass="mediumred" Visible="false"> No entries posted.</asp:Panel> </td> </tr> <tr> <td align="left" valign="top" colspan="3" width="100%" style="padding-top: 3px;"> </td> </tr> <tr style="visibility: hidden; display: none;"> <td> </td> </tr> </table> </td> <td> </td> </tr> </table></asp:Content>I would try commenting out these lines:
debugger;var groupid = '<%=Request.QueryString["GroupID"].ToString()%>';window.radopen("ActivityEntry.aspx?GroupID=" + groupid, "UserListDialog");window.radopen("ActivityEntry.aspx", "UserListDialog")
sry for late reply... its urgent requirement so i did it in normal asp controls.
Yes,i have tried to click on "Add New Event"it doesnt fire properly.even i checked click 'edit'.it doesnt work.but before binding the 1st grid to 2nd grid it worked good, not now
Here's my setup:
Main.Master
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Main.Master.vb" Inherits="FOS.NET.Main" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <link rel="stylesheet" type="text/css" href="../common/RAMPS.css" /> <link rel="stylesheet" type="text/css" href="../common/subModal.css" /> <!--Remove this link when going to production --> <link rel="stylesheet" type="text/css" href="../RAMPS.css" /> <title>FOS</title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> </telerik:RadAjaxManager> <!-- Code removed for brevity --> </form></body></html>Main.Master.vb
Imports Telerik.Web.UIImports System.Web.ServicesImports System.Data.SqlClient Partial Public Class Main Inherits System.Web.UI.MasterPage Friend Event RebindDetailGrid As CommandEventHandler Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) 'handle the manager AjaxRequest event here If e.Argument = "CashCashEquivalents_BindData" Then RaiseEvent RebindDetailGrid(Me, New CommandEventArgs("BindDetailGrid", e.Argument.ToString)) End If End Sub End ClassContent Page AssetSchedule:
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Main.Master" CodeBehind="AssetSchedule.aspx.vb" Inherits="FOS.NET.AssetSchedule" %><%@ MasterType VirtualPath="~/Main.Master" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function openRadWindow(url, windowName, x, y) { var radWindow1 = $find("<%= RadWindow1.ClientID %>"); radWindow1.show(); radWindow1.setSize(x, y); radWindow1.center(); radWindow1.setUrl(url); radWindow1.set_title(windowName); } function ShowInsertForm(url) { var radgrid = $find('<%= RadGridAssetSchedule.ClientID %>'); var clientID = radgrid.get_masterTableView().get_dataItems()[0].getDataKeyValue("ClientID"); openRadWindow(url + clientID, 'Insert New Record', 540, 450); return false; } function OnClientClose(sender, args) { if (args.get_argument() != null) { var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>"); //alert("'" + sender.get_name() + "'" + " was closed and returned the following argument: '" + args.get_argument() + "'"); ajaxManager.ajaxRequest(args.get_argument()); } } </script> </telerik:RadCodeBlock></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderBody" runat="server"> <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGridAssetSchedule" /> <telerik:AjaxUpdatedControl ControlID="CashCashEquivalents" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGridAssetSchedule"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGridAssetSchedule" /> <telerik:AjaxUpdatedControl ControlID="CashCashEquivalents" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManagerProxy> <telerik:RadWindowManager ID="RadWindowManager1" runat="server"> </telerik:RadWindowManager> <telerik:RadWindow ID="RadWindow1" runat="server" VisibleStatusbar="false" OffsetElementID="offsetElement" KeepInScreenBounds="false" OnClientClose="OnClientClose"> </telerik:RadWindow> <telerik:RadGrid ID="RadGridAssetSchedule" runat="server" AllowSorting="True" CellSpacing="0" DataSourceID="SqlDataSourceScheduleList" GridLines="None" Skin="Outlook" Font-Size="Small" AutoGenerateColumns="False" EnableViewState="False"> <FilterMenu EnableImageSprites="False"> </FilterMenu> <ClientSettings> <Selecting CellSelectionMode="None"></Selecting> </ClientSettings> <MasterTableView DataSourceID="SqlDataSourceScheduleList" AllowFilteringByColumn="False" AllowPaging="False" DataKeyNames="Report,ClientID" ClientDataKeyNames="Report,ClientID" Name="ScheduleList" EnableViewState="False"> <DetailTables> <telerik:GridTableView runat="server" Name="CashCashEquivalents" DataSourceID="SqlDataSourceCashEquivalent" EditMode="InPlace" CommandItemDisplay="Top" ShowFooter="True" AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="True" DataKeyNames="CashEquivalentID,ClientID" ClientDataKeyNames="CashEquivalentID,ClientID"> <CommandItemSettings ExportToPdfText="Export to PDF" /> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True"> <HeaderStyle Width="20px" /> </ExpandCollapseColumn> <Columns> <telerik:GridEditCommandColumn FilterControlAltText="Filter EditCommandColumn column" ButtonType="ImageButton" EditImageUrl="\images\Edit.png" InsertImageUrl="\images\Edit.png" HeaderText="Edit"> <ItemStyle HorizontalAlign="Center" Width="25px" /> </telerik:GridEditCommandColumn> <telerik:GridTemplateColumn UniqueName="TemplateDetailsColumn" HeaderText="Details"> <ItemTemplate> <asp:HyperLink ID="DetailEdit" runat="server" Text="Details" ImageUrl="\images\Detail.png"></asp:HyperLink> </ItemTemplate> <ItemStyle HorizontalAlign="Center" Width="25px" /> </telerik:GridTemplateColumn> <telerik:GridDropDownColumn DataField="Owner" DataSourceID="SqlDataSourceClientOwnerCodes" FilterControlAltText="Filter Owner column" HeaderText="Owner" ListTextField="OwnerDescription" ListValueField="FOSOwnerCodeID" UniqueName="Owner"> </telerik:GridDropDownColumn> <telerik:GridBoundColumn FilterControlAltText="Filter column1 column" HeaderText="Description" UniqueName="Description" DataField="Description" MaxLength="100" DefaultInsertValue=" 1"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="AccountNumber" FilterControlAltText="Filter AccountNumber column" HeaderText="Account Number" MaxLength="15" UniqueName="AccountNumber" DefaultInsertValue="2"> <HeaderStyle Width="110px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Purpose" FilterControlAltText="Filter Purpose column" HeaderText="Purpose" MaxLength="10" UniqueName="Purpose" DefaultInsertValue="3"> </telerik:GridBoundColumn> <telerik:GridNumericColumn DataField="Rate" DataType="System.Decimal" DecimalDigits="2" FilterControlAltText="Filter InterestRate column" HeaderText="Interest Rate" UniqueName="InterestRate" DefaultInsertValue="4"> <HeaderStyle Width="80px" /> </telerik:GridNumericColumn> <telerik:GridDateTimeColumn DataField="ValuationDate" DataType="System.DateTime" FilterControlAltText="Filter ValuationDate column" HeaderText="Valuation Date" UniqueName="ValuationDate" DataFormatString="{0:MM/dd/yyyy}" DefaultInsertValue="01/01/2012"> <HeaderStyle Width="130px" /> </telerik:GridDateTimeColumn> <telerik:GridNumericColumn DataField="MarketValue" DataType="System.Decimal" DecimalDigits="2" FilterControlAltText="Filter MarketValue column" HeaderText="Market Value" NumericType="Currency" UniqueName="MarketValue" Aggregate="Sum" FooterAggregateFormatString="{0:C}" DefaultInsertValue="5"> <HeaderStyle Width="100px" /> </telerik:GridNumericColumn> <telerik:GridNumericColumn DataField="FOSAssetOXM2ID" DataType="System.Int64" DecimalDigits="2" Display="False" FilterControlAltText="Filter FOSAssetOXM2ID column" HeaderText="FOSAssetOXM2ID" UniqueName="FOSAssetOXM2ID"> </telerik:GridNumericColumn> <telerik:GridNumericColumn DataField="CashEquivalentID" DataType="System.Int64" DecimalDigits="2" Display="False" FilterControlAltText="Filter CashEquivalentID column" HeaderText="CashEquivalentID" UniqueName="CashEquivalentID"> </telerik:GridNumericColumn> <telerik:GridNumericColumn DataField="Schedule" DataType="System.Int64" DecimalDigits="2" Display="False" FilterControlAltText="Filter Report column" HeaderText="Schedule" UniqueName="Schedule"> </telerik:GridNumericColumn> <telerik:GridButtonColumn ConfirmText="Delete this Asset?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" HeaderText="Delete"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" Width="25px" /> </telerik:GridButtonColumn> <telerik:GridBoundColumn DataField="ClientID" Display="False" FilterControlAltText="Filter ClientID column" HeaderText="ClientID" UniqueName="ClientID"> </telerik:GridBoundColumn> </Columns> <CommandItemTemplate> <a href="#" onclick="return ShowInsertForm('/ScheduleDetailForms/DetailCashEquivalents.aspx?ClientID=');"> Add New Record</a> </CommandItemTemplate> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"> </EditColumn> </EditFormSettings> </telerik:GridTableView> </DetailTables> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="Type" FilterControlAltText="Filter Type column" HeaderText="Type" ReadOnly="True" SortExpression="Type" UniqueName="Type"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Description" FilterControlAltText="Filter Description column" HeaderText="Description" ReadOnly="True" SortExpression="Description" UniqueName="Description"> <HeaderStyle Width="950px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Report" FilterControlAltText="Filter Report column" HeaderText="Report" ReadOnly="True" SortExpression="Report" UniqueName="Report" DataType="System.Int32" Display="False"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="FOSAssetScheduleLinkID" DataType="System.Int32" Display="False" FilterControlAltText="Filter FOSAssetScheduleLinkID column" HeaderText="FOSAssetScheduleLinkID" ReadOnly="True" SortExpression="FOSAssetScheduleLinkID" UniqueName="FOSAssetScheduleLinkID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="OXM2ClientID" Display="False" FilterControlAltText="Filter OXM2ClientID column" HeaderText="OXM2ClientID" ReadOnly="True" SortExpression="OXM2ClientID" UniqueName="OXM2ClientID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ClientID" DataType="System.Int32" Display="False" FilterControlAltText="Filter ClientID column" HeaderText="ClientID" ReadOnly="True" SortExpression="ClientID" UniqueName="ClientID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="OrderBy" DataType="System.Int32" Display="False" FilterControlAltText="Filter OrderBy column" HeaderText="OrderBy" ReadOnly="True" SortExpression="OrderBy" UniqueName="OrderBy"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="MissingPricingData" FilterControlAltText="Filter MissingPricingData column" HeaderText="Missing Pricing Data" ReadOnly="True" SortExpression="MissingPricingData" UniqueName="MissingPricingData"> </telerik:GridBoundColumn> </Columns> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"> </EditColumn> </EditFormSettings> </MasterTableView> </telerik:RadGrid></asp:Content>AssetSchedules.aspx.vb
Imports Telerik.Web.UIPartial Public Class AssetSchedule Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load AddHandler Master.RebindDetailGrid, AddressOf RebindDetailGrid End Sub Friend Sub RebindDetailGrid(ByVal sender As Object, ByVal e As CommandEventArgs) Dim item As GridDataItem = DirectCast(RadGridAssetSchedule.Items(0), GridDataItem) 'Accessing first item Dim tableView As GridTableView = DirectCast(item.ChildItem.NestedTableViews(0), GridTableView) ' rebind DetailTable of first item tableView.Rebind() End SubEnd ClassDetailCashEquivalents.aspx (Popup Window from AssetSchedules)
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DetailCashEquivalents.aspx.vb" Inherits="FOS.NET.DetailCashEquivalents" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <link rel="stylesheet" type="text/css" href="../common/RAMPS.css" /> <link rel="stylesheet" type="text/css" href="../common/subModal.css" /> <!--Remove this link when going to production --> <link rel="stylesheet" type="text/css" href="../RAMPS.css" /> <script language="javascript" type="text/javascript"> function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit); else countfield.value = maxlimit - field.value.length; } function pageLoad() { //txtInput = document.getElementById('txtUserInput'); var currentWindow = GetRadWindow(); //txtInput.value = currentWindow.argument; } function GetRadWindow() { var oWindow = null; if (window.radWindow) oWindow = window.radWindow; else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; return oWindow; } function Close() { GetRadWindow().Close(null); } function ReturnArgs() { var oWindow = GetRadWindow(); oWindow.close('CashCashEquivalents_BindData'); } </script> <title>Cash & Equivalents Detail</title> <style type="text/css"> .columnStyle1 { width: 230px; } </style></head><body> <form id="form2" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> <asp:Label ID="LabelRadWindowClose" runat="server" Width="410px"></asp:Label> <%--Label used for closing window--%> <asp:FormView ID="FormView1" runat="server" DataKeyNames="CashEquivalentID" DataSourceID="SqlDataSourceCashEquivalent" DefaultMode="Insert"> <!-- Edited for brevity --> </asp:FormView> <!-- Edited for brevity --> </form></body></html>Help with Javascript Rebind - Posted on Mar 27, 2008
Solved by Chris Ruegsegger - Posted on Aug 13, 2008
http://www.telerik.com/community/forums/aspnet-ajax/grid/help-with-javascript-rebind.aspx#606974http://www.telerik.com/community/forums/aspnet-ajax/grid/help-with-javascript-rebind.aspx#2093389
it's possible to reactivate the demo link ,all link in the forum doesn't work
http://demos.telerik.com/aspnet/prometheus/Controls/Examples/Integration/GridAndWindow/DefaultCS.aspx?product=grid
thanks
Olivier
I have a page with four Radtabs on it and in one of the tab I have a RadGrid and a Gridbuttoncoloumn.
On click of gridbuttoncoloumn, i want it to redirect it to another tab on the same page..In the Radgrid1_itemcommand event, i am checking the command name of my button coloumn and redirecting it to other tab something like this
radtabstrip1.selectedindex =2;
radmultipage1.selectedindex = 2;
but its not working as expected.
Hey guys,
I decided to post the solution to my problem. I was given this project and it contained both the RadAjaxPanel and RadAjaxManager. In the documentation it notes that using these together can cause problems here:
"If the same control is placed in a RadAjaxPanel as well as included in RadAjaxManager settings as an AJAXified control (i.e., it is AJAXified by both the RadAjaxPanel and RadAjaxManager),the RadAjaxManager's setting will not work."
It seems to be common sense but just in case someone is still having this issue, double check this. In my case, I just had to move my client-side radgrid rebinding to server-side withing my OnAjaxRequest method. I don't know if this will help anyone but there you go.
Hi all,
sorry for resurecting an old post, but im having this problem, also.
in my case my rebinds are from code behind, i have a form to insert the values into the database, all works fine and at this point it rebinds the radgrid, the problems happens if i delete on line of radgrid it updates the radgrid but, when i user the form to insert values, it inserts on DB, but stops refreshing the radgrid, i have to press the refresh button to refresh the grid any ideas?
Best Regards
It is possible that there is a error that prevents the update of the grid and you could inspect the browser's console for such error. If you are using RadAjaxMananger to enable the AJAX you need to ensure that the insert button is set in the AJAX settings to update the grid. Finally, if you are manually calling the Rebind method of the Grid, you could try to set the DataSource of the grid to empty collection before calling the Rebind method.
Hope this helps.
Best regards,
Konstantin Dikov
the Telerik team
Hi,
I already tryed that ones and nothing, the button is on ajaxseetings and nothing, the only way thats working for now its forcing from javascript to rebind the windows.
In terms os erros nothing detected on console.
Best Regards
Without a sample project replicating the issue it will be difficult to guess what might be causing the problem, but I would assume that it is related to the AJAX settings of the RadAjaxManager. With that in mind, please ensure that the button is included in the AJAX settings and that the button is set to update the RadGrid (or the windows that you are referring to).
You can also open a regular support ticket with a sample, runnable project demonstrating the problem, so we can debug it locally.
Regards,
Konstantin Dikov
Telerik by Progress
