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..
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<div class="sfcode"> <script><br /> function fill() {<br /> jQuery("#jqGrid").jqGrid({<br /> url: '@Url.Content("~/Handler/GetAjaxGridData")',<br /> datatype: 'json',<br /> height: 'auto',<br /> altRows: true,<br /> loadonce:true,<br /> pager: '#pager',<br /> rowNum: 3,<br /> colNames: ['birim_adi', 'durum'],<br /> colModel: [<br /> { name: 'cell.birim_adi', index: 'birim_adi' },<br /> { name: 'cell.durum', index: 'durum' }<br /> ],<br /> jsonReader: {<br /> repeatitems: false,<br /> root: function (obj) { return obj.rows; },<br /> page: function (obj) { return 1; },<br /> total: function (obj) { return 1; },<br /> records: function (obj) { return obj.rows.length; }<br /> },<br /> loadComplete: function (data) {<br /> var total_pages = $("#sp_1_pager").text(); // total pages<br /> $('#hdn_total_pages').val(total_pages);<br /> },<br /> ajaxGridOptions: { cache: false }<br /> });<br /> }<br /> function loop() {<br /> var i = 1;<br /> setInterval(function () {<br /> var total_pages = $('#hdn_total_pages').val();<br /> $("#jqGrid").setGridParam({<br /> datatype: 'json', // <--When I delete it goes to another page, but the page does not refresh.<br /> page: i,<br /> }).trigger('reloadGrid');<br /> i++;<br /> if (i > total_pages) { i = 1; }<br /> }, 5000);<br /> }<br /> </script><br /> <script><br /> $(function () {<br /> fill();<br /> loop();<br /> });<br /> </script><br /> <table id="jqGrid"></table><br /> <div id="pager"></div><br /> <input type="hidden" id="hdn_total_pages" value="1" /></div> |
and then my json like this:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<div class="sfcode"> {<br /> "total": 1,<br /> "page": 1,<br /> "records": 6,<br /> "rows": [<br /> {<br /> "id": 1,<br /> "cell": {<br /> "birim_adi": "a",<br /> "durum": "test"<br /> }<br /> },<br /> {<br /> "id": 2,<br /> "cell": {<br /> "birim_adi": "b",<br /> "durum": "test1"<br /> }<br /> },<br /> {<br /> "id": 3,<br /> "cell": {<br /> "birim_adi": "c",<br /> "durum": "test3"<br /> }<br /> },<br /> {<br /> "id": 4,<br /> "cell": {<br /> "birim_adi": "d",<br /> "durum": "test4"<br /> }<br /> }<br /> ]<br /> }</div> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top