Date Will Not Filter Correctly After Using Formatter on jqGrid Column - jqgrid

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.

Related

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.

how to set the jqgrid column width, and re-sizable, in a scrollable jqgrid?

i am using jqgrid and facing a problem with column width
here is my js code
jQuery(document).ready(function () {
var grid = jQuery("#grid");
grid.jqGrid({
url: '/Admin/GetUserForJQGrid',
datatype: 'json',
mtype: 'Post',
cellsubmit: 'remote',
cellurl: '/Admin/GridSave',
//formatCell: emptyText,
colNames: ['Id', 'Privileges', 'First Name', 'Last Name', 'User Name', 'Password', 'Password Expiry', 'Type', 'Last Modified', 'Last Modified By', 'Created By', ''],
colModel: [
{ name: 'Id', index: 'Id', key: true, hidden: true, editrules: { edithidden: true } },
{ name: 'Privileges', index: 'Privileges', width: "350", resizable: false, editable: false, align: 'center', formatter: formatLink, classes: 'not-editable-cell' },
{ name: 'FirstName', index: 'FirstName', width:350, align: "left", sorttype: 'text', resizable: true, editable: true, editrules: { required: true } },
{ name: 'LastName', index: 'LastName',width:350, align: "left", sorttype: 'text', resizable: true, editable: true, editrules: { required: true } },
{ name: 'UserName', index: 'UserName', width:300,align: "left", sorttype: 'text', resizable: true, editable: true, editrules: { required: true } },
{ name: 'Password', index: 'Password',width:400, align: "left", sorttype: 'text', resizable: true, editable: false, editrules: { required: true }, classes: 'not-editable-cell' },
{
name: 'Password_Expiry',width:250, index: 'Password_Expiry', align: "left", resizable: true, editable: true, editoptions: {
size: 20, dataInit: function (el) {
jQuery(el).datepicker({
dateFormat: 'yy-mm-dd', onSelect: function (dateText, inst) {
jQuery('input.hasDatepicker').removeClass("hasDatepicker")
return true;
}
});
}
}
},
{
name: 'Type', width: "250", index: 'Type', sorttype: 'text', align: "left", resizable: true, editable: true, editrules: { required: true }, edittype: 'select', editoptions: {
value: {
'Normal': 'Normal',
'Sales': 'Sales',
'Admin': 'Admin',
'SuperAdmin': 'SuperAdmin'
},
dataEvents: [
{
type: 'change',
fn: function (e) {
var row = jQuery(e.target).closest('tr.jqgrow');
var rowId = row.attr('id');
jQuery("#grid").saveRow(rowId, false, 'clientArray');
}
}
]
}
},
{ name: 'Modified',width:250, index: 'Modified', sorttype: 'date', align: "left", resizable: true, editable: false, classes: 'not-editable-cell' },
{ name: 'ModifiedBy', width:250, index: 'ModifiedBy', sorttype: 'text', align: "left", resizable: true, editable: false, classes: 'not-editable-cell' },
{ name: 'CreatedBy', width:250,index: 'CreatedBy', sorttype: 'text', align: "left", resizable: true, editable: false, classes: 'not-editable-cell' },
{ name: 'Delete',width:50, index: 'Delete', width: 25, resizable: false, align: 'center', classes: 'not-editable-cell' }
],
rowNum: 10,
rowList: [10, 20, 50, 100],
sortable: true,
delete: true,
pager: '#pager',
height: '100%',
width: "650",
afterSubmitCell: function (serverStatus, rowid, cellname, value, iRow, iCol) {
var response = serverStatus.responseText;
var rst = 'false';
debugger;
if (response == rst) {
debugger;
setTimeout(function () {
$("#info_dialog").css({
left: "644px", // new left position of ERROR dialog
top: "380px" // new top position of ERROR dialog
});
}, 50);
return [false, "User Name Already Exist"];
}
else {
return [true, ""];
}
},
//rowNum: 10,
//rowList: [10, 20, 50, 100],
sortable: true,
loadonce: false,
ignoreCase: true,
caption: 'Administration',
search: false,
del: true,
cellEdit: true,
hidegrid: false,
pgbuttons : false,
pginput : false,
//viewrecords: true,
gridComplete: function () {
var ids = grid.jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++) {
var isDeleted = grid.jqGrid('getCell', ids[i], 'Delete');
if (isDeleted != 'true') {
grid.jqGrid('setCell', ids[i], 'Delete', '<img src="/Images/delete.png" alt="Delete Row" />');
}
else {
grid.jqGrid('setCell', ids[i], 'Delete', ' ');
}
}
}
}
);
grid.jqGrid('navGrid', '#pager',
{ resize: false, add: false, search: false, del: false, refresh: false, edit: false, alerttext: 'Please select one user' }
).jqGrid('navButtonAdd', '#pager',
{ title: "Add New users", buttonicon: "ui-icon ui-icon-plus", onClickButton: showNewUsersModal, position: "First", caption: "" });
});
i need a scrollable grid , when use come to this page i have to show the first 7 columns only just seven in full page. i have 11 columns in my grid rest of the columns can be seen by using scroll, but first 7 should be shown when grid loads. and every column should be re-sizable. can any body help me, i will 100% mark your suggestion if it works for me ...thank you ;) . if something is not explained i am here to explain please help me
and can i save the width of column permanently when user re-size the column, so when next time grid get loads the column should have the same width which is set by the user by re-sizing.. is it possible ?
I am not sure what you want,but you can auto adjust the width with JqGrid autowidth and shrinkToFit options.
Please refer this Post jqGrid and the autowidth option. How does it work?
this will do the trick.

WepApi post parameters are null

I'm new to WebApi and I have problem with the received post parameters.
I want to populate jqgrid with data received from webapi controller method.
The grid code is as follows:
buildPostData: function (postData) {
var parameters = {
page: postData.page,
rows: postData.rows,
sidx: '',
sord: '',
_search: false,
searchField: '',
searchString: '',
searchOper: '',
filter: { groupOp: '', rules: [] }
};
$.extend(parameters, postData);
var data = {
parameters: parameters
};
return JSON.stringify(data);
}
bindGridAllData: function () {
var viewModel = this;
jQuery("#AllDataGrid").jqGrid({
url: 'api/DataApi/GetAllData',
datatype: 'json',
mtype: 'POST',
ajaxGridOptions: {
contentType: 'application/json; charset=utf-8'
},
serializeGridData: viewModel.buildPostData,
serializeRowData: function (data) {
return JSON.stringify(data);
},
jsonReader: { repeatitems: false, root: "d.rows", page: "d.page", total: "d.total", records: "d.records" },
colNames: ['DataId', 'Title', 'Description', 'Date', 'UserId', 'Name', 'Surname', 'PicturePath', 'NumberOfComments', ''],
colModel: [
{ name: 'DataId', index: 'DataId', width: 10, hidden: true, editable: false, sortable: false, key: true },
{ name: 'Title', index: 'Title', width: 10, editable: false, align: 'left', sortable: true, hidden: true },
{ name: 'Description', index: 'Description', width: 10, editable: false, align: 'left', sortable: true, hidden: true },
{ name: 'Date', index: 'Date', width: 10, editable: false, align: 'left', sortable: true, hidden: true },
{ name: 'UserId', index: 'UserId', width: 10, editable: false, align: 'left', sortable: true, hidden: true },
{ name: 'Name', index: 'Name', width: 10, editable: false, align: 'left', sortable: true, hidden: true },
{ name: 'Surname', index: 'Surname', width: 10, editable: false, align: 'left', sortable: true, hidden: true },
{ name: 'PicturePath', index: 'PicturePath', width: 10, editable: false, align: 'left', sortable: true, hidden: true },
{ name: 'NumberOfComments', index: 'NumberOfComments', width: 10, editable: false, align: 'left', sortable: true, hidden: true },
{
name: 'DataInformation', index: 'DataInformation', width: 200, editable: false, align: 'left', sortable: true, formatter: function (cellvalue, options, rowObject) {
var template = $('<div data-bind="template: { name: \'DataRecord\', data: DataRecord, ajax: { async: false } }"></div>');
var data = { DataRecord: rowObject };
ko.applyBindings(data, template[0]);
return template.html();
}
}
],
height: '100%',
width: 900,
pager: '#resultGridAllDataPager',
rowNum: 10,
rownumbers: false,
scroll: false,
sortname: 'Date',
sortorder: "asc",
gridview: true,
hoverrows: false,
viewrecords: true,
cmTemplate: { title: false },
loadComplete: function () {
}
});
}
And the WebApi method is:
[HttpPost]
public JQGridData GetAllData(JQGridSearchParameters parameters)
{
using (dataMKbazaEntities context = new dataMKbazaEntities())
{
JQGridData grid = new JQGridData();
var allData = context.ispolniSITEpodatoci().ToList();
List<object> data = new List<object>();
foreach (var ad in allData)
{
data.Add(new {
DataId=ad.podatokID,
Title=ad.naslov,
Description=ad.opis,
Date=ad.datum,
UserId=ad.idKORISNIK,
Name=ad.ime,
Surname=ad.prezime,
PicturePath=ad.slika,
NumberOfComments=ad.brojKOMENTARI
});
}
grid.rows = data;
grid.page = parameters.page;
grid.records = data.Count;
grid.total = (int)Math.Ceiling((float)data.Count / (float)parameters.rows);
return grid;
}
}
When sending data, parameters have values defined from buildPostData method but when received in WepApi controller method they are null.
I have tried with [FromBody] in webapi method but with no success.
Status code in http request is 200 OK
Make sure of the following:
Your raw request has the Content-Type header. Looking at your client code you seem to be sending it, but just wanted to make sure that it is indeed sent over the wire. Web API had a bug where if you do not send Content-Type header, since we do not know which formatter to deserialize the content, we default to the default value of the C# type. In this case it could be 'null'. This has been fixed later and is not yet publicly available though.
Have the following check to see any model state errors:
if (!ModelState.IsValid)
{
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, this.ModelState));
}

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