1. Use the setgridparm after putting data in jqgrid
grid.setGridParam({ rowNum: 4, total: 3, page: 1, records: 5 }).trigger("reloadGrid");
2. Keep the datatype as "local" while creating jqGrid.
3. Width of the grid is not auto adjusted, keep it enough so that pager is visible.
======================
function bb() {
$.ajax({
type: "POST",
url: "Service.svc/DoWork1",
dataType: "json",
success: function(result) {
alert(result.d);
var data = JSON.parse(result.d).rows;
var grid = $("#tablegrid");
var i = 0;
for (i = 0; i < data.length; i++) {
grid.addRowData(i + 1, data[i]);
}
grid.setGridParam({ rowNum: 4, total: 3, page: 1, records: 5 }).trigger("reloadGrid");
}
});
}
======================
$("#tablegrid").jqGrid({
mtype: "GET",
datatype: "local",
colNames: ["id", "name"],
colModel: [
{ name: "id", index: "id", width: 55 },
{ name: "name", index: "name", width: 55}
],
pager : "#pager",
width : 600
}
https://docs.google.com/file/d/0B5tau-GpaqtCY01aT1hsUlFfc0k/edit?usp=sharing
grid.setGridParam({ rowNum: 4, total: 3, page: 1, records: 5 }).trigger("reloadGrid");
2. Keep the datatype as "local" while creating jqGrid.
3. Width of the grid is not auto adjusted, keep it enough so that pager is visible.
======================
function bb() {
$.ajax({
type: "POST",
url: "Service.svc/DoWork1",
dataType: "json",
success: function(result) {
alert(result.d);
var data = JSON.parse(result.d).rows;
var grid = $("#tablegrid");
var i = 0;
for (i = 0; i < data.length; i++) {
grid.addRowData(i + 1, data[i]);
}
grid.setGridParam({ rowNum: 4, total: 3, page: 1, records: 5 }).trigger("reloadGrid");
}
});
}
======================
$("#tablegrid").jqGrid({
mtype: "GET",
datatype: "local",
colNames: ["id", "name"],
colModel: [
{ name: "id", index: "id", width: 55 },
{ name: "name", index: "name", width: 55}
],
pager : "#pager",
width : 600
}
https://docs.google.com/file/d/0B5tau-GpaqtCY01aT1hsUlFfc0k/edit?usp=sharing
No comments:
Post a Comment