Can you provide a javascript example for refreshing/reloading the grid client-side?
I want to migrate the following UltraWebGrid js code: grid.invokeXmlHttpRequest(grid.eReqType.Refresh);
Hi,
The WebDataGrid does not have such a client-side method. The best approach would be to wrap it inside of the UpdatePanel and do a refresh on that.
http://weblogs.asp.net/jeffreyzhao/archive/2008/04/26/refresh-the-updatepanel-using-javascript-code.aspx
-Taz
I have tried your solution. However it doen't work in my application, because I use the grid inside a websplitter pane. The grid is not displayed in IE8 nor in Google Chrome on startup. The grid shows in IE7 compatibility mode.
Below you find the aspx of my test page:
< body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server" /> </div> <ig:websplitter id="cSplitter" runat="server" enableviewstate="false" SkinId="Vertical" Width="100%" Height="100%"> <Panes> <ig:SplitterPane runat="server"> <Template> <asp:UpdatePanel ID="gridPanel" runat="server"> <ContentTemplate> <ig:WebDataGrid ID="mainGrid" runat="server" EnableAppStyling="False" EnableViewState="False" /> </ContentTemplate> </asp:UpdatePanel> </Template> </ig:SplitterPane> <ig:SplitterPane runat="server" CollapsedDirection="NextPane" Size="200px" ContentUrl="about:blank" FrameBorder="False" /> </Panes> </ig:websplitter> </form></ body>
<
body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
</div>
<ig:websplitter id="cSplitter" runat="server" enableviewstate="false" SkinId="Vertical" Width="100%" Height="100%">
<Panes>
<ig:SplitterPane runat="server">
<Template>
<asp:UpdatePanel ID="gridPanel" runat="server">
<ContentTemplate>
<ig:WebDataGrid ID="mainGrid" runat="server" EnableAppStyling="False" EnableViewState="False" />
</ContentTemplate>
</asp:UpdatePanel>
</Template>
</ig:SplitterPane>
<ig:SplitterPane runat="server" CollapsedDirection="NextPane" Size="200px" ContentUrl="about:blank" FrameBorder="False" />
</Panes>
</ig:websplitter>
</form>
</
Did you ever find a solution to this?
I am running into the same issue.
I need to to a client side ajax refresh of a WebDataGrid.
Thanks,Jeff
The _rc attribute is the total record count.
The Page_Load code snippet seems to be copied wrong. Corrected version.
protected void Page_Load(object sender, EventArgs e){ grid.GridResponse.AdditionalProperties.Add("_rc", RecordCount);}
JS function j_dataGridRefresh forces the VirtualScrolling behavior to run. JS function j_dataGridAJAXResponse is the client side event handler and registered like this:
grid.ClientEvents.AJAXResponse =
"j_dataGridAJAXResponse";
The purpose of j_dataGridAJAXResponse is to force the grid to do some postprocessing, because I had layout problems.
Perhap it is best if you try to use j_dataGridRefresh and only use the page_load code and the j_dataGridAJAXResponse if you get unexpected results.
I don't fully understand how this code is wired up. How are the functions called? Also, the Page_Load example code snippeet is confusing to me.
Please advise.
That's just the trick I've been hoping to find, thanks!
I understand what the j_dataGridRefresh is doing, but what's the AJAXResponse and the _rc attribute there for?
Jeff,
The UpdatePanel did not show the WebDataGrid in IE8 and Chroome, because its height was not set correctly. I added the following CSS rule to my stylesheet. (igspl_Pane is the CSS class of the websplitter).
.igspl_Pane > DIV { height : 100%;}
However I do not use the UpdataPanel. I already used the VirtualScrollingBehavior. I have created a client-side refresh javascript function (j_dataGridRefresh) and I use the clientside event AJAXResponse (j_dataGridAJAXResponse).
c#:
protected void Page_Load(object sender, EventArgs e){ grid.GridResponse.AdditionalProperties.Add(
"_rc", RecordCount);}
function
j_dataGridAJAXResponse(sender, args) { if (args.get_gridResponseObject !== undefined) { var responseObject = args.get_gridResponseObject();
if (responseObject) { var rc = responseObject.AdditionalProperties["_rc"];
if (rc || rc === 0) { var behaviors = sender.get_behaviors(); var virtualScrolling = behaviors.getBehaviorByName("VirtualScrolling"); virtualScrolling._recordCount = rc; virtualScrolling._onInitVerticalHeight(virtualScrolling._vsb()); } } }}