I've been working on this issue all weeken and have read almost every post and demo related to the RadGrid and to the RadAjaxManager, Hopefully I've posted enough informatio to get a clear understanding of my issue
I’m using a CommandItem Templete to add a new record to a grid with a custom form. I have the “add new record” linkbutton working but I need some help with the grid refresh when the radWindow closes. I'm using the sample that opens a radWindow and then passes back informtion to the parent form with the OnClientClose . I’m also using DotNetNuke as my platform and I’ve creates a usercontrol for my module. I would like the Grid to refresh when I close the radWindow that has the form. I’m using the return to parent that is in one of the demos but I cannot get any type of grid refresh to work outside of calling a page reload. It seems that the problem is in the fact that I need to programmatically add the radAjaxManager programmatically to the page. I’ve tried using
Dim manager As New RadAjaxManager()
manager.ID = "RadAjaxManager1"
Me.Page.Form.Controls.Add(manager)
But if I try to immediately test it with
value = TryCast(Me.Page.Items(GetType(RadAjaxManager)), RadAjaxManager) I come back with nothing.
Also if I put
function refreshGrid(arg) {
if (!arg) {
var mgr = $find('<%=RadAjaxManager.GetCurrent(Page).ClientID %>');
mgr.ajaxRequest("Refresh")
return false;
}
}
I get this error:
A critical error has occurred.Object reference not set to an instance of an object.
I have added:
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
The bottom line is that I cannot get the RadAjaxManager1_AjaxRequest to fire so I can run RadGrid1.MasterTableView.SortExpressions.Clear()
RadGrid1.MasterTableView.GroupByExpressions.Clear()
RadGrid1.Rebind()
I have added window.location.reload(true); to the OnClientClose function and that refreshes the grid currently but that is not the smoothest way. All help is appreciated.
Bill
| function CheckChanged(sender, invoiceNumber) { |
| var listbox = $find("<%=lstInvoiceNoteEntry.ClientID %>"); |
| if (sender.checked) { |
| var item = new Telerik.Web.UI.RadListBoxItem(); |
| item.set_text(invoiceNumber); |
| listbox.trackChanges(); |
| listbox.get_items().add(item); |
| listbox.commitChanges(); |
| } |
| else { |
| var item = listbox.findItemByText(invoiceNumber); |
| listbox.trackChanges(); |
| while (item) { |
| listbox.get_items().remove(item); |
| item = listbox.findItemByText(invoiceNumber); |
| } |
| listbox.commitChanges(); |
| } |
| } |
<asp:ScriptManager runat="server" ID="ScriptManager1" /> <div class="SearchTitle">Notes</div> <asp:Label runat="server" ID="lblStatus" /><br /><br /> <telerik:RadGrid ID="gvSomeTable" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="dsSomeTable" AllowPaging="true" PageSize="25" AllowFilteringByColumn="true" ShowStatusBar="true"> <ClientSettings Selecting-AllowRowSelect="true" EnableRowHoverStyle="true" EnablePostBackOnRowClick="true"> <ClientEvents OnRowSelected="showNote" OnRowContextMenu="RowContextMenu" /> </ClientSettings> <MasterTableView DataKeyNames="someID" ClientDataKeyNames="someID" CommandItemDisplay="Top"> <Columns> <telerik:GridDateTimeColumn DataField="startTime" HeaderText="Date of Event" SortExpression="startTime" /> <telerik:GridBoundColumn DataField="CompName" HeaderText="Company" SortExpression="CompName"> <FilterTemplate> <telerik:RadComboBox ID="cboCompany" Runat="server" Width="250px" DataSourceID="dsCompanyList" DataTextField="Company" DataValueField="Company" AllowCustomText="true" MarkFirstMatch="true" EmptyMessage="Filter by Company" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("CompanyName").CurrentFilterValue %>' OnClientSelectedIndexChanged="CompanyIndexChanged" /> <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> <script type="text/javascript"> function CompanyIndexChanged(sender, args) { var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>"); tableView.filter("CompanyName", args.get_item().get_value(), "EqualTo"); } </script> </telerik:RadScriptBlock> </FilterTemplate> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="feederFundList" AllowFiltering="false" HeaderText="Fund" SortExpression="FundList"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="categoryList" AllowFiltering="false" HeaderText="Category" SortExpression="categoryList"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="AddedBy" HeaderText="By" SortExpression="AddedBy"> <FilterTemplate> <telerik:RadComboBox ID="cboUserList" Runat="server" Width="250px" DataSourceID="dsUserList" DataTextField="AddedBy" DataValueField="AddedBy" AllowCustomText="true" MarkFirstMatch="true" EmptyMessage="Filter by User" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("AddedBy").CurrentFilterValue %>' OnClientSelectedIndexChanged="userIndexChanged" /> <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server"> <script type="text/javascript"> function userIndexChanged(sender, args) { var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>"); tableView.filter("AddedBy", args.get_item().get_value(), "EqualTo"); } </script> </telerik:RadScriptBlock> </FilterTemplate> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn DataField="AddedOn" HeaderText="On" SortExpression="AddedOn" /> <telerik:GridHyperLinkColumn AllowFiltering="false" DataNavigateUrlFields="someID" DataNavigateUrlFormatString= "~/Events/somepage.aspx?someID={0}" Text="Edit" /> <telerik:GridBoundColumn AllowFiltering="false" DataField="dateRead" Visible="false" ReadOnly="true" /> </Columns> </MasterTableView> </telerik:RadGrid>