I'm using jqgrid 4.8.2. I'm trying to follow along with the examples on the demo site. I've created a parent grid and need to show a subgrid (as a grid). For some reason, the toolbar pager for the subgrid won't display. The rowNum, width and height options are working, though. I've looked at the demo and I can't see what I'm doing wrong. Would someone take a look at the following code, please?
var lastSelection;
$(document).ready(function () {
$("#jqGrid").jqGrid({
url: 'servlet/getData',
datatype: "json",
editurl: "servlet/updateProduct",
page: 1,
colModel: [
{ label: 'ID', name: 'ProductId', width: 75, key: true },
{ label: 'Category', name: 'CategoryName', width: 90 },
{ label: 'Name', name: 'ProductName', width: 100 },
{ label: 'Country', name: 'Country', width: 80 },
{ label: 'Price', name: 'Price', width: 80 },
{ label: 'Qty', name: 'Quantity', width: 80 },
{ label: 'Included?', name: 'Included', width: 80,
editable: true,
edittype: "checkbox",
editOptions: {value:"Yes:No"} }
],
viewrecords: true, // show the current page, data range and total records on the toolbar
onSelectRow: function (rowid) {
var grid = $('#jqGrid');
if (rowid && rowid !== lastSelection) {
grid.jqGrid('restoreRow', lastSelection);
lastSelection = rowid;
}
grid.jqGrid('editRow', lastSelection, {keys: true,
extraparam : {
home: "livonia",
productName: function(){
var row = grid.getRowData(lastSelection);
// Both of these work:
var temp = row.ProductName;
var temp1 = row['ProductName'];
return row.ProductName;
}
}
}
);
},
width: 780,
height: 200,
rowNum: 10,
pager: "#jqGridPager",
subGrid: true,
subGridRowExpanded: function(subgrid_id, row_id) {
var lastSubgridSelection;
var grid = $('#jqGrid');
var row = grid.getRowData(row_id);
var productId = row.ProductId;
var subgrid_table_id;
subgrid_table_id = subgrid_id + "_t";
jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table>");
jQuery("#"+subgrid_table_id).jqGrid({
url: 'servlet/getProductWarehouses?q=2&id=' + row_id + '&productId=' + productId,
datatype: "json",
page: 1,
colModel: [
{ label: 'Product ID', name: 'ProductId', width: 75, key: false, hidden: true },
{ label: 'Whse ID', name: 'WhseId', width: 90, key: true },
{ label: 'Whse Name', name: 'WhseName', width: 90 },
{ label: 'Qty', name: 'Quantity', width: 80 },
{ label: 'Included?', name: 'Included', width: 80,
editable: true,
edittype: "checkbox",
editOptions: {value:"Yes:No"} }
],
viewrecords: true,
height: '100%',
width: 400,
rowNum: 5,
pager: "#jqGridPager" + "_" + subgrid_id
});
}
});
});
See Question&Answers more detail:
os