How to properly set the jsonReader of a jqGrid to handle string array of rows - jqgrid

Here are my column and model items:
var col_names = ['Qty', 'SFC', 'Item Nbr', 'Brand', 'Product', 'Supplier', 'Price', 'UOM', 'Case', 'Remarks', 'Weight', 'Par', 'Sort', 'Purchased', 'ProductId'];
var col_model = [
{ name: 'Quantity', index: 'Quantity', width: 22, sorttype: "number", editable: true, edittype: 'text', editoptions: { size: 10, maxlength: 15} },
{ name: 'ProductAttributes', index: 'ProductAttributes', width: 50 },
{ name: 'ItemNum', index: 'ItemNum', width: 50, align: "right"},
{ name: 'BrandName', index: 'BrandName', width: 100 },
{ name: 'ProducName', index: 'ProducName', width: 150 },
{ name: 'SupplierName', index: 'SupplierName', width: 100 },
{ name: 'Price', index: 'Price', width: 40, sorttype: "number", align: "right" },
{ name: 'UOM', index: 'UOM', width: 30 },
{ name: 'CasePack', index: 'CasePack', width: 30 },
{ name: 'PackageRemarks', index: 'PackageRemarks', width: 80 },
{ name: 'AveWeight', index: 'AveWeight', width: 33, align: "right" },
{ name: 'Par', index: 'Par', width: 20, align: "right", editable: true, edittype: 'text', editoptions: { size: 10, maxlength: 15} },
{ name: 'SortPriority', index: 'SortPriority', hidden: true },
{ name: 'LastPurchaseDate', index: 'LastPurchaseDate', width: 50, align: "right" },
{ name: 'ProductId', index: 'ProductId', hidden: true, key: true },
];
here's the grid initialization
favoriteGrid = $('#favoriteGrid');
favoriteGrid.jqGrid({
url: '/xxx/yyy/zzz/',
datatype: 'json',
ajaxGridOptions: { contentType: "application/json" },
jsonReader: {
id: "ProductId",
cell: "",
root: function (obj) { return obj.rows; },
page: function () { return 1; },
total: function () { return 1; },
records: function (obj) { return obj.rows.length; },
repeatitems: false
},
colNames: col_names,
colModel: col_model,
pager: $('#favoritePager'),
pginput: false,
rowNum: 1000,
autowidth: true,
sortable: true, // enable column sorting
multiselect: true, // enable multiselct
gridview: true,
ignoreCase: true,
loadonce: true, // one ajax call per
loadui: 'block',
loadComplete: function () {
fixGridHeight(favoriteGrid);
},
ondblClickRow: function (rowid, ri, ci) {
},
onSelectRow: function (id) {
if (id && id !== lastSel) {
favoriteGrid.restoreRow(lastSel);
lastSel = id;
}
favoriteGrid.editRow(id, true);
},
gridComplete: function () {
}
}).jqGrid('navGrid', '#favoritePager',
{ add: false, edit: false, del: false, search: true, refresh: false },
{},
{},
{},
{ multipleSearch: true, showQuery: false },
{}).jqGrid('sortableRows').jqGrid('gridDnD');
and finally, the data:
{"rows":[["1",null,"342240"," ","15 AMP, 600V, TIME DELAY, CLASS G","Home Depot - Canada","3.83","EA","1","- 15A, 600V - Class G - Mfg #SC-15","0.02","","0",null,"2977175133"],["1",null,"3573375","NEWPRT","STEAK TOP SIRLOIN CH CC 8OZ","SYSCO","6.875","LB","24 PK","8 OZ","24 LB","","0",null,"1675949601"],["1",null,"201805"," ","GE-HOTPOINT DISHWASHER UPPER RACK","Home Depot - Canada","54.43","EA","1","Dishwasher Upper Rack - Fits Models #HDA2000, HDA2100 And GSD2100 - Mfg #WD28X10011","6.5","","0",null,"2977172115"],["1",null,"286044"," ","GE DISHWASHER SILVERWARE BASKET","Home Depot - Canada","19.19","EA","1","Silverware Basket - Mfg #WD28X265","0.06","","0",null,"2977172688"]]}
I get the right number of rows and the columns but no data is displayed in the grid, if that makes sense.
Just for completeness:
[HandleJsonException]
public JsonResult ProductGroupService(Int64 id = 0)
{
var q = Repository.GetFavoriteProducts(SimpleSessionPersister.User.Id, id).ToArray();
var result = (from fp in q
select new string[]
{
Convert.ToString(fp.Quantity),
fp.ProductAttributes,
fp.ItemNum,
fp.BrandName,
fp.ProducName,
fp.SupplierName,
Convert.ToString(fp.Price),
fp.UOM,
fp.CasePack,
fp.PackageRemarks,
fp.AveWeight,
Convert.ToString(fp.Par),
Convert.ToString(fp.SortPriority),
fp.LastPurchaseDate,
Convert.ToString(fp.ProductId)
}).ToArray();
var jsonData = new
{
rows = result
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
Thank you,
Stephen

You main problem is that you used repeatitems: false property of the jsonReader which is wrong for your input.
Moreover you should remove trailing comma at the end of definition of col_model. The error will be ignored by many modern browsers, but not for the old one.
After the changed the grid will be successfully loaded: see the demo.

Related

jqgrid loading on Button Click

Jqgrid load with data on pageload. When I try to load the grid on a button click grid load with the data but in the next moment the full grid get disappear if I use the grid on a content page with master page and the rows get disappear if I use a page without master page. Is there any solution for this? Thanks
Added a demo
Note: grid is disappearing on every postback
When I removed the update panel from master page , grid is not disappearing but the data on the grid is disappering
jQuery("#jqgItemDetails").jqGrid({
url: '',
datatype: "local",
colNames: ['UPC Code', 'OLD UPC', 'Item Description', 'Old Item Desc', 'Size UOM', 'Old Size UOM', 'Department', 'Category',
'Tax Description', 'WIC/CVV', 'Label', 'Last Movement', 'Last Purchase', 'Item Added', 'Comment', 'Store Number'],
colModel: [
{ name: 'UPC_Code', index: 'UPC_Code', width: 90, stype: 'text' },
{ name: 'UPC_Code_Old', index: 'UPC_Code_Old', width: 90, stype: 'text', hidden: true },
{ name: 'Item_Desc', index: 'Item_Desc', width: 150 },
{ name: 'Item_Desc_Old', index: 'Item_Desc_Old', width: 150, hidden: true },
{ name: 'Size_UOM', index: 'Size_UOM', width: 60 },
{ name: 'Size_UOM_Old', index: 'Size_UOM_Old', width: 60, hidden: true },
{ name: 'Department', index: 'Department', width: 100 },
{ name: 'Category', index: 'Category', width: 80 },
{ name: 'Tax_Desc', index: 'Tax_Desc', width: 150 },
{ name: 'WIC_CVV', index: 'WIC_CVV', width: 80 },
{ name: 'Label', index: 'Label', width: 150 },
{ name: 'Last_Movement', index: 'Last_Movement', width: 100 },
{ name: 'Last_Purchase', index: 'Last_Purchase', width: 100 },
{ name: 'Item_Added', index: 'Item_Added', width: 100 },
{ name: 'Comment', index: 'Comment', width: 100, editable: true },
{ name: 'Store_Number', index: 'Store_Number', width: 100, hidden: true }
],
multiselect: true,
rowNum: 10,
sortname: 'UPC_Code',
viewrecords: true,
sortorder: "desc",
pager: '#pager2',
width: 1100,
cellEdit: true,
cellsubmit: 'clientArray',
editurl: '',
height: 60,
onSelectRow: editRow,
shrinkToFit: false,
afterSaveCell: function (rowid, name, val, iRow, iCol) {
var grid = $("#jqgItemDetails");
if (name == 'Comment') {
grid.jqGrid('setCell', rowid, 'Comment', val);
}
},
caption: '<span style="height:20px;color:#cc961a">UPC Item Details</span>'
});
var lastSelection;
function editRow(id) {
if (id && id !== lastSelection) {
var grid = $("#jqgItemDetails");
grid.jqGrid('restoreRow', lastSelection);
grid.jqGrid('editRow', id, { keys: true });
lastSelection = id;
}
}
function btnUPCShow_OnClientClick() {
fillUPCDetailsGrid();
}
function fillUPCDetailsGrid() {
var UPCCol = new Array();
var UPCData = "", UPCLike = "", RangeFrom = "", RangeTo = "", FilterVal;
FilterVal = document.getElementById('ddlFilter').value;
if (FilterVal == 1) {
UPCData = document.getElementById('txtUPC').value; // '77098103440,77098103450,77098103470,77098104423'; // document.getElementById('txtUPC').value;
UPCCol = UPCData.split(',');
}
else if (FilterVal == 2) {
UPCLike = document.getElementById('txtUPC').value;
}
else if (FilterVal == 3) {
RangeFrom = document.getElementById('txtUPC').value;
RangeTo = document.getElementById('txtRangeTo').value;
}
$.ajax({
type: "POST",
url: 'ItemInquiries.aspx/GetUPCDetails',
data: JSON.stringify({ UPCCollection: UPCCol, UPCLike: UPCLike, UPCRangeFrom: RangeFrom, UPCRangeTo: RangeTo, Filter: FilterVal }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (Result) {
var myjsongrid = $.parseJSON(Result.d);
for (var i = 0; i < myjsongrid.Table.length; i++) {
jQuery('#jqgItemDetails').jqGrid('addRowData', i + 1, myjsongrid.Table[i]);
}
}
});
}

JqGrid is called during page load but next time when am calling it on button click it is not getting called

$(document).ready(function () {
BindGrid('', '', '', '', 1, 2, '', '', sessionStorage.UserID);
});
function Search() {
$('#modal_Advance_Search').modal('hide');
var channelselected = $('#dd_channel option:selected');
var channelarray = [];
$(channelselected).each(function (index, channelsel) {
channelarray.push([$(this).val()]);
});
var Channel = channelarray.toString();
var Distselected = $('#dd_dist_category option:selected');
var Distarray = [];
$(Distselected).each(function (index, channelsel) {
Distarray.push([$(this).val()]);
});
var DistributorCategory = Distarray.toString();
var ARNNo = "";
var token = $("#txt_arn").tokenInput("get");
var names = [];
$.each(token, function (i, obj) {
names.push(obj.name);//build an array of just the names
});
ARNNo = names.toString();
sessionStorage.setItem("DistributorCategoryMaster", DistributorCategory);
sessionStorage.setItem("ChannelCreateMaster", Channel);
sessionStorage.setItem("ARNCreateMaster", ARNNo);
sessionStorage.setItem("ismasterqueue", true);
$("#hdr_name").text("Master Q");
$("#spn_user_name").text(sessionStorage.UserName);
$("#spn_role_name").text(sessionStorage.RoleName);
BindGrid(ARNNo, Channel, '', DistributorCategory, 1, 2, Utility.ListSearchText, '', sessionStorage.UserID)
}
function BindGrid(ArnNo1, Channel1, ARNName1, DistributorCategory1, Status1, MasterQueueStatus1, SearchFilter1, MemoLevel1, UserID1) {
$("#tbl_masterqueue").jqGrid({
url: "/Pages/MSQ.aspx/GetCreateBaseRackRate",
mtype: 'POST',
postData:
{
ArnNo: ArnNo1, Channel: Channel1, ARNName: ARNName1, DistributorCategory: DistributorCategory1, Status: Status1, MasterQueueStatus: MasterQueueStatus1, SearchFilter: SearchFilter1, MemoLevel: MemoLevel1, UserID: UserID1
},
datatype: "json",
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
serializeGridData: function (postData) {
return JSON.stringify(postData);
},
jsonReader: {
repeatitems: false,
root: function (obj) { return obj.d; }
},
colNames: ['Select', 'Memoid', 'Memo Number', 'Memo Type', 'Memo Type ID', 'Category', 'ARN No', 'ARN Name', 'Date From', 'Date To', 'Status', 'Status', 'Raised By', 'Raised On', 'Time', 'Ageing', 'Last Action By', 'Pending With'],
colModel: [
{ name: 'edi', index: 'edi', formatter: MasterQueue.ReturnRadioBox, width: '60px;', disabled: true, hidden: true, sortable: false },
{ name: 'PaymentMemoId', index: 'PaymentMemoId', width: 120, hidden: true, sortable: false },
{ name: 'MemoNumber', index: 'MemoNumber', align: 'center', formatter: MasterQueue.ReturnSearchHyperLink, sortable: false },
{ name: 'MemoTypeName', index: 'MemoTypeName', width: 120, sortable: false },
{ name: 'MemoTypeID', index: 'MemoTypeID', hidden: true, sortable: false },
{ name: 'DistributorCategoryName', index: 'DistributorCategoryName', width: 260, sortable: false },
{ name: 'ARNNo', index: 'ARNNo', width: 90, sortable: false },
{ name: 'ARNName', index: 'ARNName', width: 260, sortable: false },
{ name: 'DateFrom', index: 'DateFrom', sorttype: "date", align: 'center', width: 90, sortable: false },
{ name: 'DateTo', index: 'DateTo', align: 'center', width: 90, sortable: false },
{ name: 'MemoStatus', index: 'MemoStatus', align: 'center', width: 90, hidden: true, sortable: false },
{ name: 'MemoStatusDisplay', index: 'MemoStatusDisplay', align: 'center', width: 90, sortable: false },
{ name: 'CreatedByName', index: 'CreatedByName', align: 'left', sortable: false },
{ name: 'RaisedOnDate', index: 'RaisedOnDate', width: 90, align: 'center', sortable: false },
{ name: 'RaisedOnTime', index: 'RaisedOnTime', width: 50, align: 'center', sortable: false },
{ name: 'Ageing', index: 'Ageing', width: 70, align: 'right', sortable: false },
{ name: 'ModifiedByName', index: 'ModifiedByName', align: 'left', sortable: false },
{ name: 'PendingWith', index: 'PendingWith', align: 'left', sortable: false },
],
rowNum: 100,
rowList: [100, 200, 300, 400, 500],
pager: '#pager',
sortname: 'PaymentMemoId',
viewrecords: true,
sortorder: "desc",
gridview: true,
height: '510px',
loadonce: true,
gridview: true
});
jQuery("#tbl_masterqueue").jqGrid('navGrid', '#pager', { add: false, edit: false, del: false, search: true, refresh: true },
{}, {}, {}, { multipleSearch: true, multipleGroup: true, showQuery: true });
}
I have created one method to bind grid during pageload,its working fine but again when am calling the same method during filtering/searching on button click this method is not working.I am using JQGrid,please help to fix.

JqGrid paging with lots of grids

I have a single page ASP.Net web forms application. And lots of grids. In my application, there is some links to hide or show grids. The problem is, when i start the application, the pagination of the displayed grid is working properly. (I tried this for each grid). But when I Click the link for hide a grid and show another grid, paging does not working. The grid initialization is;
$('#tblApplicationSettings').jqGrid({
url: cms.util.getAjaxPage(),
cellLayout: cms.theme.list.cellLayout,
hoverrows: false,
forceFit: true,
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
cell: "",
id: "0"
},
width: 900,
height: 400,
datatype: 'local',
colNames: ['SettingId',
'Description',
'Name',
'Value',
'ServerId',
'IsReadOnly',
''
],
colModel: [
{
name: 'SettingId',
index: 'SettingId',
hidden: true
},
{
name: 'Description',
index: 'Description',
search: false,
editable: true,
sortable: false,
width: 150,
inlineEditable: true
},
{
name: 'Name',
index: 'Name',
search: false,
editable: false,
sortable: false,
width: 150,
inlineEditable: false
},
{
name: 'Value',
index: 'Value',
search: false,
editable: true,
sortable: false,
width: 250,
inlineEditable: true,
},
{
name: 'ServerId',
index: 'ServerId',
search: false,
editable: true,
sortable: false,
width: 150,
formatter: 'select',
edittype: 'select',
editoptions: {
value: options,
},
inlineEditable: true
},
{
name: 'IsReadOnly',
index: 'IsReadOnly',
hidden: true
},
{
name: 'JsUsage',
index: 'JsUsage',
search: false,
editable: true,
sortable: false,
width: 150,
inlineEditable: true
},
],
onSelectRow: function (id) {
if (id && id !== lastSelection) {
jQuery('#grid').jqGrid('restoreRow', lastSelection);
lastSelection = id;
}
var columnModel = $('#grid').getGridParam('colModel');
var colNames = new Array();
$.each(columnModel, function (index, column) {
colNames.push(column.name);
if (isReadOnly || !column.inlineEditable) {
column.editable = false;
}
else {
column.editable = true;
}
if (column.edittype == "select") {
column.editoptions.dataEvents = [{
type: 'change',
fn: function (e) {
var newServerId = $(this).val();
that.isServerIdChanged = true;
if (newServerId == "null") {
}
}
}]
}
});
var row = $('#grid').getRowData(id);
var isReadOnly = row.IsReadOnly == "true" ? true : false;
if (isReadOnly) {
alert("row is not editable");
return null;
}
jQuery("#grid").jqGrid('editRow', id, {
keys: true,
extraparam: {
dataType: 'updateSetting',
colNames: JSON.stringify(colNames),
settingName: row.Name,
settingId: row.SettingId
},
successfunc: function (result) {
$("#grid").trigger('reloadGrid');
}
});
},
editurl: '/Ajax.ashx',
rowNum: 25,
direction: "ltr",
scroll: 1,
gridview: true,
pager: '#divPager',
viewrecords: true,
});
$('#grid').setGridParam({ datatype: "json", postData: { dataType: 'getSettings' } });
$('#grid').jqGrid('navGrid', '#divPager', { edit: false, add: false, del: false, search: false, refresh: false });
$('#grid').trigger('reloadGrid');
like this for all grids. I need tips or helps. Thanks.

jqSubGrid not loading with data

I do realize many have asked this same question. I have tried all other suggestions and have had no success. I know for sure its something I am overlooking and wanted a second set of eyes to help me. Thanks in advance!!
My problem is that the primary grid loads find. Its the sub grid thats the problem.
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#PositionsGrid").jqGrid({
url: '/Position/GetPositions?projectid=#Model.ID',
datatype: 'json',
mtype: 'POST',
colNames: ['PositionID', 'ID', 'Job', 'Band', 'Start Date', 'End Date','Current Assignee','Terminated Worker','Status'],
colModel: [
{ name: 'PositionID', index: 'PositionID', width: 20, align: 'left', hidden: true, sortable: false, search: false,key:true },
{ name: 'DisplayID', index: 'DisplayID', width: 50, align: 'left' },
{ name: 'JobTitle', index: 'JobTitle', width: 100, align: 'left' },
{ name: 'Band', index: 'Band', width: 50, align: 'left' },
{ name: 'StartDate', index: 'StartDate', width: 50, align: 'left', searchoptions: { sopt: ['cn'], dataInit: datePick} },
{ name: 'EndDate', index: 'EndDate', width: 50, align: 'left', searchoptions: { sopt: ['cn'], dataInit: datePick} },
{ name: 'CurrentWorker', index: 'CurrentWorker', width: 100, align: 'left' },
{ name: 'TerminatedWorker', index: 'TerminatedWorker', width: 100, align: 'left' },
{ name: 'Status', index: 'Action', width: 50, align: 'left', search: false}],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'PositionID',
sortorder: "asc",
viewrecords: true,
autowidth: true,
subGrid: true,
subGridRowExpanded: showDetails
});
$('#PositionsGrid').jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch: 'cn' });
$("#PositionGrid").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, search: false, refresh: true });
});
datePick = function (elem) {
$(elem).datepicker({ dateFormat: "mm/dd/yy", onSelect: function (dateText, inst) { $("#grid")[0].triggerToolbar(); } });
};
function showDetails(subgrid_id, row_id) {
showSubGrid_AssignmentsGrid(subgrid_id, row_id, "<br><b>Worker History</b><br><br>", "AssignmentsGrid");
}
function showSubGrid_AssignmentsGrid(subgrid_id, row_id, message, suffix) {
var subgrid_table_id;
subgrid_table_id = subgrid_id + "_t";
if (message) jQuery('#' + subgrid_id).append(message);
if (message) jQuery('#' + subgrid_id).append(message);
jQuery("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table>");
jQuery("#" + subgrid_table_id).jqGrid({
url: "Position/GetAssignmentsByPosition?positionid=" + row_id,
datatype: "json",
colNames: ['AssignID', 'JobReqNum', 'WorkerName', 'StartDate', 'EndDate','Status'],
colModel: [
{ name: "AssignID", index: "AssignID", width: 80},
{ name: "JobReqNum", index: "JobReqNum", width: 130 },
{ name: "WorkerName", index: "WorkerName", width: 80, align: "right" },
{ name: "StartDate", index: "StartDate", width: 80, align: "right" },
{ name: "EndDate", index: "EndDate", width: 100, align: "right" },
{ name: "Status", index: "Status", width: 100, align: "right" }
],
height: '100%',
rowNum: 20,
sortname: 'AssignID',
sortorder: "asc"
});
}
</script>
the controller action that loads the subgrid is below
public JsonResult GetAssignmentsByPosition(int positionid)
{
ProjPosition position = uow.PositionRepository.GetPosition(positionid);
var jsonRows = position.ProjPositionAssignments.AsEnumerable()
.Select(a => new
{
cell = new string[] { a.ID.ToString(),
a.JobReqNum == null ? "" :a.JobReqNum,
a.Worker == null ? "" : a.Worker.FullName,
(a.StartDate == null) ? "" : ((DateTime)a.StartDate).ToString("MM/dd/yyyy"),
(a.EndDate == null) ? "" : ((DateTime)a.EndDate).ToString("MM/dd/yyyy"),
(a.Status == null ? "Active" : StatusDictionary.AssignmentStatusDictionary[a.Status])
}
})
.ToArray();
var jsonData = new
{
rows = jsonRows
};
return Json(jsonData);
}
You also need to pass to jqgrid:
page = numberOfPages
records = totalRecords,
I personally use something like:
var jsonData = new
{
total = (totalRecords + rows - 1) / rows,
page = page,
records = totalRecords,
rows = (
from item in pagedQuery
select new
{
cell = new string[] {
item.value1,
item.value2, ....
}
}).ToArray()
};
return Json(jsonData, JsonRequestBehavior.AllowGet);

problem loading data in details jqGrid from master grid?

When I am making a call first time it shows data in my details grid from master grid but when selecting other row its not populating the new data in the details grid..
jQuery("#list10").jqGrid({
sortable: true,
url: '/cpsb/unprocessedOrders.do?method=getInitialUnprocessedList',
datatype: 'json',
colNames: ['Order', 'Load', 'Gate Time', 'Stop', 'Customer', 'Status'],
colModel: [
{ name: 'orderNumber', index: 'orderNumber', width: 120, align: "center",
sorttype: "int", key: true },
{ name: 'loadNumber', index: 'loadNumber', width: 100, align: "center",
sorttype: "int" },
{ name: 'latestTime', index: 'latestTime', width: 160, align: "center",
align: "center" },
{ name: 'stopSeq', index: 'stopSeq', width: 80, align: "center",
sorttype: "int" },
{ name: 'customerNumber', index: 'customerNumber', width: 60,
align: "center", sorttype: "int" },
{ name: 'orderStatus', index: 'orderStatus', width: 120, align: "center" }
],
rowNum: 10,
rowList: [10, 20, 30],
jsonReader: { repeatitems: false,
root: function (obj) {
return obj;
},
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.length; }
},
pager: '#pager10',
sortname: 'Gate Time',
sortorder: "desc",
gridview: true,
loadonce: true,
viewrecords: true,
multiselect: true,
multikey: 'ctrlKey',
caption: "Order Header",
onSelectRow: function (ids) {
if (ids == null) {
ids = 0;
if (jQuery("#list10_d").jqGrid('getGridParam', 'records') > 0) {
jQuery("#list10_d").jqGrid('setGridParam', { url:
"/cpsb/unprocessedOrders.do?method=getUnprocessedOrderDetails&orderNum=" + ids });
jQuery("#list10_d").jqGrid('setCaption',
"Order Header: " + ids).trigger('reloadGrid');
}
}
else {
jQuery("#list10_d").jqGrid('setGridParam', { url:
"/cpsb/unprocessedOrders.do?method=getUnprocessedOrderDetails&orderNum=" + ids });
jQuery("#list10_d").jqGrid('setCaption',
"Order Details: " + ids).trigger('reloadGrid');
}
},
height: '100%'
});
jQuery("#list10").jqGrid('navGrid','#pager10',
{view:true,add:false,edit:false,del:false,searchtext:"Filter"},
{},{},{},{multipleSearch:true});
$("#list10").jqGrid('hideCol', 'cb');
2nd grid for order details
jQuery("#list10").jqGrid('reloadGrid');
jQuery("#list10_d").jqGrid({
height: 100,
url: "/cpsb/unprocessedOrders.do?method=getUnprocessedOrderDetails&orderNum=",
datatype: "json",
colNames: ['Order', 'SKU', 'UPC', 'Item Description', 'Quantity Ordered',
'Teach in Hold?'],
colModel: [
{ name: 'orderNumber', index: 'orderNumber', width: 55 },
{ name: 'sku', index: 'sku', width: 55 },
{ name: 'upc', index: 'upc', width: 40, align: "right" },
{ name: 'itemDescription', index: 'itemDescription', width: 150,
align: "right" },
{ name: 'quantityOrdered', index: 'quantityOrdered', width: 150,
align: "right", sortable: false, search: false },
{ name: 'teachInId', index: 'teachInId', width: 150,
align: "right", editable: true, edittype: "checkbox",
formatter: 'checkbox', editoptions: { value: "true:false"} }],
rowNum: 5,
rowList: [5, 10, 20],
jsonReader: { repeatitems: false,
root: function (obj) {
return obj;
},
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.length; }
},
pager: '#pager10_d',
sortname: 'SKU',
loadonce: true,
viewrecords: true,
sortorder: "asc",
multiselect: true,
multikey: 'ctrlKey',
caption: "Order Detail",
height: '100%'
}).navGrid('#pager10_d', { view: true, add: false, edit: false, del: false },
{}, {}, {}, { multipleSearch: true });
$("#list10_d").jqGrid('hideCol', 'cb');
jQuery("#ms1").click(function () {
var s;
s = jQuery("#list10_d").jqGrid('getGridParam', 'selarrrow');
alert(s);
});
Edit: I am able view different records once I refresh the page...But after one selection other selection don't work
edit2: after debugging i saw that I am appending the orderNum parameter correctly but this is not making any call to the action class....any idea? thanks!
It seems to me that the answer on your main problem you find here: JqGrid Reload not working.
Because you use loadonce:true in both grids, the datatype in every grid will be changed from "json" to "local" after the first load. It seems to me that you should just remove loadonce:true for the second (detailed) grid. If you do want use loadonce:true for example for local sorting or local paging, then you should reset datatype to "json" in the same call jQuery("#list10_d").jqGrid('setGridParam',{url:"...", datatype: "json"}); .

Resources