I am trying to add a row to the grid through javascript in response to a web service response. I am loading the grid initially and then I want to refresh the grid by polling for any changes to the data on the server. I want to refresh the grid on the client without having to refresh the page or doing a full load each time. Can someone show me how to get the WebDataGrid and add a row received in xml format in javascript?
Here is the code snippet I am using
<script type="text/javascript">
}
function ConstantCall() {
BigBrother.WebService.UpdateData(pts,OnComplete, OnTimeOut, OnError);
if (data != null) {
xmlDoc.loadXML(data);
function OnTimeOut(data) { alert("timeout"); }
<body onload="BLOCKED SCRIPTInitConstantCall()">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
</Services>
</asp:ScriptManager>
<div>
<asp:Label ID="PollTimeStamp" runat="server"></asp:Label>
<asp:Label ID="Data" runat="server"></asp:Label>
StyleSetName="Office2007Silver" AutoGenerateColumns="False" >
<Behaviors>
<ig:ColumnResizing>
</ig:ColumnResizing>
<ig:Selection CellClickAction="Row" RowSelectType="Single">
</ig:Selection>
<ig:Sorting>
</ig:Sorting>
<ig:Paging PageSize="10">
</ig:Paging>
</Behaviors>
<Columns>
Alex,
I tried doing the following to add new row to webdatagrid.
employee = new Array();employee[0] = "Some text";
grid.get_rows().add(employee[0]);
But I got InvalidCasException. (Unable to cast object of type 'System.String' to type 'System.Object['
What should be arrayOfCellValues?
Thanks,
Proper syntax would be:
grid.get_rows().add(employee);
However it seems that there is a problem with the add method which we caught on our end. It will be addressed in the next hot fix, which will enable it to accept an array again. For now the method accepts only an object in which properties are the column keys. So for your example it would be something like:
var employee = {"EmployeeName":"Some text"};