Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Add a child row to a grid through javascript
posted

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">

var DelayInSeconds = 5; function InitConstantCall() {setTimeout('ConstantCall()', DelayInSeconds * 1000);

}

function ConstantCall() {

var pts = '<% = PollTimeStamp.Text %>';

BigBrother.WebService.UpdateData(pts,OnComplete, OnTimeOut, OnError);

setTimeout(
'ConstantCall()', DelayInSeconds * 1000);

}

function OnComplete(data) { var grid = $find("grdSummary");

if (data != null) {

    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

    xmlDoc.loadXML(data);

     ig_AddNew("grdSummary",0);

}

}

function OnError(data) {alert("error"); }

function OnTimeOut(data) { alert("timeout"); }

</script> </head>

<body onload="BLOCKED SCRIPTInitConstantCall()">

<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server">

<Services>

<asp:ServiceReference Path="~/WebService.asmx" />

</Services>

</asp:ScriptManager>

<div>

<asp:Label ID="PollTimeStamp" runat="server"></asp:Label>

<asp:Label ID="Data" runat="server"></asp:Label>

<ig:WebDataGrid ID="grdSummary" runat="server" Height="563px" Width="100%"

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>