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);
Related
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]);
}
}
});
}
Here is my current column model:
colModel: [
{ name: 'LastName', index: 'LastName', width: 120, align: 'center' },
{ name: 'FirstName', index: 'FirstName', width: 120, align: 'center' },
{ name: 'MiddleName', index: 'MiddleName', width: 120, align: 'center' },
{ name: 'DOB', index: 'DOB', width: 100, align: 'center' },
{ name: 'id', index: 'id', align: 'center', hidden: true },
{ name: 'checked', index: 'checked', align: 'center', hidden: true },
{ name: 'courtType', index: 'courtType', align: 'center', editable: true, sortable: false, width: 100 },
{ name: 'CaseNumber', index: 'CaseNumber', align: 'center', editable: true, sortable: false, width: 100 },
{ name: 'CourtFileNumber', index: 'CourtFileNumber', align: 'center', editable: true, sortable: false, width: 100 },
{ name: 'WarrantDocket', index: 'WarrantDocket', align: 'center', editable: true, sortable: false, width: 100 },
{ name: 'Sentencing', index: 'Sentencing', align: 'center', editable: true, sortable: false, width: 100 },
{ name: 'notes', index: 'notes', align: 'center', editable: true, sortable: false, width: 400 },
{ name: 'name', index: 'name', width: 200,
sortable: true,
align: 'center',
editable: true,
cellEdit: true,
edittype: 'select',
formatter: 'select',
editoptions: { value: getAllSelectOptions() }
}
],
This gives me a dropdown list from getAllSelectOptions().
function getAllSelectOptions() {
var states = { '1': 'Alabama', '2': 'California', '3': 'Florida',
'4': 'Hawaii', '5': 'London', '6': 'Oxford'
};
return states;
}
Is there a way to get a different list for each row based on its ID and a webmethod call (or some other way)?
var createCourtGridURL = AdminPath + "WebMethods/Kernel/Court.asmx/GetGetdData";
var jqGridDataURL = AdminPath + "WebMethods/Kernel/Court.asmx/GetSelectData";
Edit: Working Code
var myGrid = $('#selectedInmateList'),
decodeErrorMessage = function (jqXHR, textStatus, errorThrown) {
var html, errorInfo, i, errorText = textStatus + '\n' + errorThrown;
if (jqXHR.responseText.charAt(0) === '[') {
try {
errorInfo = $.parseJSON(jqXHR.responseText);
errorText = "";
for (i = 0; i < errorInfo.length; i++) {
if (errorText.length !== 0) {
errorText += "<hr/>";
}
errorText += errorInfo[i].ExceptionType + ": " + errorInfo[i].Message;
}
}
catch (e) { }
} else {
html = /<body.*?>([\s\S]*)<\/body>/i.exec(jqXHR.responseText);
if (html !== null && html.length > 1) {
errorText = html[1];
} else {
errorText = jqXHR.responseText.replace(/\n/, "<br>");
}
}
return errorText;
},
buildSelectFromJson = function (data) {
var html = '<select>', d = data.d, length = d.length, i = 0, item;
for (; i < length; i++) {
item = d[i];
html += '<option value=' + item + '>' + item + '</option>';
}
html += '</select>';
return html;
};
myGrid.jqGrid({
url: createCourtGridURL,
datatype: 'json',
ajaxGridOptions: { contentType: "application/json" },
ajaxSelectOptions: { contentType: "application/json", dataType: 'json'/*, type: "POST"*/ },
serializeGridData: function (postData) {
if (postData.filters === undefined) postData.filters = null;
return JSON.stringify(postData);
},
mtype: 'POST',
colNames: ['Id', 'Last Name', 'First Name', 'Middle Name', 'DOB', 'Checked', 'User'],
colModel: [
{ name: 'id', index: 'id', align: 'center', hidden: true },
{ name: 'LastName', index: 'LastName', width: 120, align: 'center' },
{ name: 'FirstName', index: 'FirstName', width: 120, align: 'center' },
{ name: 'MiddleName', index: 'MiddleName', width: 120, align: 'center' },
{ name: 'DOB', index: 'DOB', width: 100, align: 'center' },
{ name: 'checked', index: 'checked', align: 'center', hidden: true },
{ name: 'User', index: 'User', width: 400, editable: true,
stype: 'select', edittype: 'select',
/*
searchoptions: {
sopt: ['cn', 'nc', 'bw', 'bn', 'eq', 'ne', 'ew', 'en', 'lt', 'le', 'gt', 'ge'],
dataUrl: jqGridDataURL,
buildSelect: buildSelectFromJson
},
*/
editoptions: {
sopt: ['cn', 'nc', 'bw', 'bn', 'eq', 'ne', 'ew', 'en', 'lt', 'le', 'gt', 'ge'],
dataUrl: function () {
var rowID = selectedRowId = myGrid.jqGrid('getGridParam', 'selrow');
return jqGridDataURL + '?id=' + rowID;
},
buildSelect: buildSelectFromJson,
dataEvents: [
{
type: 'change',
fn: function (e) {
//alert('change event')
}
}
]
}
}
],
pager: '#pager',
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'Id',
sortorder: 'desc',
rownumbers: true,
viewrecords: true,
height: '100%',
cellEdit: true,
multiselect: true,
cellsubmit: 'clientArray', //?
pager: '#selectedInmatePager',
gridview: true,
jsonReader: {
root: "d.rows",
page: "d.page",
total: "d.total",
records: "d.records",
cell: ""
},
caption: 'Selected Court Inmates',
loadError: function (jqXHR, textStatus, errorThrown) {
// remove error div if exist
$('#' + this.id + '_err').remove();
// insert div with the error description before the grid
myGrid.closest('div.ui-jqgrid').before(
'<div id="' + this.id + '_err" style="max-width:' + this.style.width +
';"><div class="ui-state-error ui-corner-all" style="padding:0.7em;float:left;"><span class="ui-icon ui-icon-alert" style="float:left; margin-right: .3em;"></span><span style="clear:left">' +
decodeErrorMessage(jqXHR, textStatus, errorThrown) + '</span></div><div style="clear:left"/></div>');
},
loadComplete: function () {
// remove error div if exist
$('#' + this.id + '_err').remove();
}
});
myGrid.jqGrid('navGrid', '#selectedInmatePager', { add: false, edit: true, del: false },
{}, {}, {}, { multipleSearch: true, overlay: false, width: 480 });
You use dataUrl already. jqGrid supports dataUrl starting with 4.5.3. So you can define dataUrl as callback which get tree parameters rowid, value, columnName. So you can return from the dataUrl the URL which contains rowid as parameter. In the case the call to the dataUrl will be different for different rows any you can implement your requirements.
I'm having some issues getting a row of Dates to filter correctly in my jqGrid. Here's a portion of my .cshtml:
<script type="text/javascript">
$(function () {
var width = $(window).width() - 50;
$("#orders_grid").jqGrid({
datatype: "local",
width: width,
height: "auto",
search: true,
autowidth: false,
shrinkToFit: true,
colNames: ['ID', 'Status', 'Category','Sub Category', 'Title', 'Owner', 'Team', 'Priority', 'Release', 'Business Line', 'Created', 'Update'],
colModel: [
{ name: 'ID', width: 12, align: 'center', sorttype: 'int'},
{ name: 'GridStatus', width: 15, align: 'center'},
{ name: 'GridCategory', width: 15, align: 'center'},
{ name: 'GridSubCategory', width: 15, align: 'center'},
{ name: 'Title', width: 60, align: 'left' },
{ name: 'GridOwnerUser', width: 20, align: 'center'},
{ name: 'GridTeam', width: 30, align: 'center'},
{ name: 'GridPriority', width: 12, align: 'center'},
{ name: 'GridRelease', width: 12, align: 'center'},
{ name: 'GridBusinessLine', width: 12, align: 'center'},
{ name: 'CreatedDateTime', width: 14, align: 'center', sortable: true, sorttype: 'd', formatter: dateFix },
{ name: 'LastUpdateDateTime', width: 14, align: 'center', sortable: true, sorttype: 'd', formatter: dateFix }
],
rowNum: 20,
rowList: [20,50,100,1000,100000],
viewrecords: true,
pager: '#gridpager',
sortname: "ID",
sortable: true,
ignoreCase: true,
headertitles: true,
sortorder: "desc",
onSelectRow: function (rowId)
{
var id = $("#orders_grid").getCell(rowId, 'ID');
document.location.href = '/TicketCenter/Display/'+ id;
}
}).navGrid("#orders_grid_pager", { edit: false, add: false, del: false }, {}, {}, {}, { multipleSearch: true, multipleGroup: false, showQuery: false, recreateFilter: true });
$("#orders_grid").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch: 'cn' });
setTimeout(function () { searchOrders('#Model.filterFor'); }, 200);
});
function dateFix(LastUpdateDateTime)
{
var x = LastUpdateDateTime.substring(6, LastUpdateDateTime.length - 2);
x = parseInt(x);
x = new Date(x);
x.setMinutes(x.getMinutes() - x.getTimezoneOffset());
x = x.format("mm/dd/yyyy h:MM TT");
return x;
}
function searchOrders(filter)
{
var data = { filter: filter }
var request = $.ajax({
url: "#Url.Action("ListTickets", "TicketCenter")",
type: "GET",
cache: false,
async: true,
data: data,
dataType: "json",
});
request.done(function (orders) {
var thegrid = $("#orders_grid");
thegrid.clearGridData();
setTimeout(function()
{
for (var i = 0; i < orders.length; i++)
{
thegrid.addRowData(i+1, orders[i]);
}
thegrid.trigger("reloadGrid");
}, 500);
});
request.fail(function(orders) {
});
}
</script>
I need to be able to search in the CreatedDateTime and LastUpdateDateTime columns. When I get my data from the database it it initially a datetime. When the grid loads, the date is displayed as "/Date102342523523463246236236", which is obviously in ticks. I formatted this with the dateFix formatter, which returns the date in mm/dd/yyyy h:MM TT format. Now when I try to search by date, I'm getting strange results. I'm thinking that the underlying data is still unformatted and it's searching off of that. Here's an example:
In my database, the CreatedDateTime for one object is 2013-10-11 20:20:10.963.
When the jqGrid loads the data, it shows /Date(1381537210963).
After I add formatter : dateFix to the colModel, it shows 10/11/2013 4:20 PM.
If I type 10 in the search box, it returns that object.
If I type 10/, it doesn't return anything.
If I type 2013, it doesn't return anything.
Is there a way to resolve this issue?
Decided to convert the date to a string in the controller before sending it to the grid. Resolved.
I've put a jqgrid the page. In Jqgrid placed a column that I want when user click on the column, Fill Other Jqgrid.Now when I click on the desired column. Only first-time Fill second JQGrid,But the next time the server side code will not run.
The code is written as follows
var firstButtonColumnIndex = 0;
grid = $('#list'); buttonNames = {};
grid.jqGrid({
url: 'jQGridHandler.ashx?Request=1',
loadonce: true,
direction: "rtl",
pgtext: "صفحه {0} از {1}",
datatype: 'json',
height: 250,
colNames: ['شماره درخواست', 'شماره اموال', 'شرح دستور کار', 'تاریخ دستور کار', 'زمان دستور کار', 'ملاحظات', '', ''],
colModel: [
{ name: 'WorkOrderNo', width: 100, sortable: true },
{ name: 'AssetNo', width: 100, sortable: true },
{ name: 'WorkDescription', width: 400, sortable: true },
{ name: 'WorkOrderDate', width: 80, sortable: true },
{ name: 'WorkOrderTime', width: 80, sortable: true },
{ name: 'Remark', width: 100, sortable: true },
{ name: 'del', width: 20, sortable: false, search: false,
formatter: function () {
return "<span class='ui-icon ui-icon-trash'></span>";
}
},
{ name: 'details', width: 20, sortable: false, search: false,
formatter: function () {
return "<span class='ui-icon ui-icon-document'></span>";
}
}
],
gridview: true,
rowNum: 10,
rowList: [10, 20, 30],
pager: '#pager',
// sortname: 'WorkOrderNo',
viewrecords: true,
sortorder: 'asc',
caption: 'درخواست ها...........',
rownumbers: true,
beforeSelectRow: function (rowid, e) {
var iCol = $.jgrid.getCellIndex(e.target);
if (iCol == 7) {
//alert("rowid=" + rowid + "\nButton name: " + buttonNames[iCol]);
// $('img').each(function () {
$("#workRequestPopUp").draggable();
// });
} else if (iCol == 8) {
workOrderId = rowid;
$("#tblRequestWorks tr").remove();
$("#tblRequestWorks").jqGrid({
// url: 'jQGridHandler.ashx?RequestWorksFill=1&workOrderId=' + workOrderId,
url: "PublicHandler.ashx?Request=1&workOrderId: rowid",
direction: "rtl",
pgtext: "",
datatype: 'json',
height: 250,
colNames: ['نام کار', 'نام واحد', 'سرپرست واحد', 'تعداد', 'پایان کار', ''],
colModel: [
{ name: 'WorkName', width: 300, sortable: true },
{ name: 'SectionName', width: 100, sortable: true },
{ name: 'SectionSupervisor', width: 100, sortable: true },
{ name: 'RequestCount', width: 80, sortable: true },
{ name: 'FinishWork', width: 100, sortable: true },
{ name: 'details', width: 20, sortable: false, search: false,
formatter: function () {
return "<span class='ui-icon ui-icon-document'></span>";
}
}
],
rowNum: 10,
rowList: [10, 20, 30],
sortorder: 'asc',
caption: 'Test',
rownumbers: true,
beforeSelectRow: function (rowid, e) {
var iCol = $.jgrid.getCellIndex(e.target);
if (iCol == 6) {
alert(rowid);
Fill12(rowid);
} else if (iCol == 8) {
alert(rowid);
Fill12(rowid);
return true;
// return (iCol >= firstButtonColumnIndex) ? false : true;
}
},
dataType: "json"
});
// fillRequestWorkPopup(workOrderId);
popup(e);
}
// prevent row selection if one click on the button
// return (iCol >= firstButtonColumnIndex) ? false : true;
return true;
}
});
It is Delegate Function in tr in JQGrid?
I respected professors can help. thanks All
The URL "PublicHandler.ashx?Request=1&workOrderId: rowid" seems me wrong. Do you mean probably "PublicHandler.ashx?Request=1&workOrderId=" + rowid? The better will be to use url: "PublicHandler.ashx" with postData: {Request: 1, workOrderId: rowid}.
The next problem is the usage of $("#tblRequestWorks tr").remove();. You don't included any HTML code which you use on the page. If you want to destroy the old grid and create a new one on the same place you should use GridUnload instead of $("#tblRequestWorks tr").remove();: $("#tblRequestWorks").jqGrid('GridUnload'); (see here and example).
You can also remove dataType: "json" from the code. jqGrid don't know the option and you already use the correct datatype: "json" option.
I think you can change your code so that the usage of GridUnload will be not needed. Only changing on some parameters of the second grid ($("#tblRequestWorks")) and reloading it with respect of $("#tblRequestWorks").trigger('reloadGrid', [{page: 1}]); seems me enough.
One more remark: you should be very careful in the id values for the second grid. It is not permitted to have id duplicates on the page. If you can't generate unique ids on the server you can consider to use idPrefix option of the 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"}); .