siva
siva

Reputation: 525

How to auto refresh jqgrid in c# mvc

Is it Possible to let the jqgrid Update itself without loading the page ?

I mean live Update

For example I want the grid to show the on line Visitors on my site but I don't want to refresh the page each time to see the new users , does jqgrid support this ?

Upvotes: 0

Views: 1511

Answers (2)

Akhilesh Maurya
Akhilesh Maurya

Reputation: 1

<script>
function refresh_grid(new_url)
{
  jQuery("#jqgrid_table").jqGrid().setGridParam({datatype:'json'});
  jQuery("#jqgrid_table").jqGrid().setGridParam({url:new_url}).trigger("reloadGrid");
  jQuery("#jqgrid_table").jqGrid().trigger("reloadGrid");
}
var myVar = setInterval(function () {myTimer()}, 1000);
function myTimer() {
 var url = " ...your url...";
 refresh_grid(url);
}

Upvotes: 0

SBirthare
SBirthare

Reputation: 5137

Option 1: Poll the changes using a timer function and call following code to load the grid:

$('#grid').trigger( 'reloadGrid' );

Option 2: Push the changes as they happen i.e. a new line visitor added using SignalR.

Upvotes: 2

Related Questions