Forum



09:18

18/12/2012

i want my jqgrid programmatically move next page with reloaded data. for example: every 5 seconds change page and get refreshed data. —> datatype: 'json' <— is in loop() function. brings reloaded page, but it does not pass the next page. stuck on the first page. if i delete it goes the next page, but the page doesn't refresh.
i read and tried, tried, tried everything but no luck as of yet. Please help..
<script> function fill() { jQuery("#jqGrid").jqGrid({ url: '@Url.Content("~/Handler/GetAjaxGridData")', datatype: 'json', height: 'auto', altRows: true, loadonce:true, pager: '#pager', rowNum: 3, colNames: ['birim_adi', 'durum'], colModel: [ { name: 'cell.birim_adi', index: 'birim_adi' }, { name: 'cell.durum', index: 'durum' } ], jsonReader: { repeatitems: false, root: function (obj) { return obj.rows; }, page: function (obj) { return 1; }, total: function (obj) { return 1; }, records: function (obj) { return obj.rows.length; } }, loadComplete: function (data) { var total_pages = $("#sp_1_pager").text(); // total pages $('#hdn_total_pages').val(total_pages); }, ajaxGridOptions: { cache: false } }); } function loop() { var i = 1; setInterval(function () { var total_pages = $('#hdn_total_pages').val(); $("#jqGrid").setGridParam({ datatype: 'json', // <--When I delete it goes to another page, but the page does not refresh. page: i, }).trigger('reloadGrid'); i++; if (i > total_pages) { i = 1; } }, 5000); } </script> <script> $(function () { fill(); loop(); }); </script> <table id="jqGrid"></table> <div id="pager"></div> <input type="hidden" id="hdn_total_pages" value="1" />
and then my json like this:
{ "total": 1, "page": 1, "records": 6, "rows": [ { "id": 1, "cell": { "birim_adi": "a", "durum": "test" } }, { "id": 2, "cell": { "birim_adi": "b", "durum": "test1" } }, { "id": 3, "cell": { "birim_adi": "c", "durum": "test3" } }, { "id": 4, "cell": { "birim_adi": "d", "durum": "test4" } } ] }
Most Users Ever Online: 715
Currently Online:
33 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66