Step 1 : Default list of data populate in table.
Step 2 : after every 30 min once i have check using polling ajax method DB and append new list with old list.
Am not able to append first and sorting also not working.
ajax polling bind the data working but append in last row.
Please help me.
table code is below
$(document).ready(function () {
jQuery("#list5").jqGrid({
url: 'server.php?q=2',
datatype: "json",
colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
colModel: [{
name: 'id',
index: 'id',
width: 55
}, {
name: 'invdate',
index: 'invdate',
width: 90
}, {
name: 'name',
index: 'name',
width: 100
}, {
name: 'amount',
index: 'amount',
width: 80,
align: "right"
}, {
name: 'tax',
index: 'tax',
width: 80,
align: "right"
}, {
name: 'total',
index: 'total',
width: 80,
align: "right"
}, {
name: 'note',
index: 'note',
width: 150,
sortable: false
}],
rowNum: 10,
rowList: [10, 20, 30],
pager: '#pager5',
sortname: 'name',
autoencode: true,
loadonce: true,
sortable: true,
viewrecords: true,
sortorder: "desc",
jsonReader: {
repeatitems: false,
id: "ID"
},
multiselect: false,
subGrid: false,
caption: "Simple data manipulation",
editurl: "someurl.php"
}).navGrid("#pager5", {
edit: false,
add: false,
del: false
});
});
Poll ajax method is below
function poll() {
var pollOutputJson;
$.ajax({
type: "POST",
url: server.php ? q = 5,
contentType : "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (data) {
pollOutputJson = data;
var samGrid = jQuery("#list5");
var su = samGrid.jqGrid('addRowData', 0, pollOutputJson);
samGrid.setGridParam({
rowNum: 15
}).trigger("reloadGrid");
},
error: function (x, e) {
alert("error occur");
}
});
setTimeout((function (param) {
return function () {
poll();
};
})(), 180000);
}