JQGrid の各列を並べ替えようとしていますが、うまくいきません。以下の私のコードを参照して、私を助けてください
//コードを表示
$("#JQGridID").jqGrid({
url: '/Control/ActionResult/',
datatype: 'json',
mtype: 'POST',
colNames: ['Number', 'Unit'],
colModel: [
{ name: 'NNumber', index: 'Number', align: 'left', sortable: true, sorttype: 'int' },
{ name: 'NUnit', index: 'Unit', align: 'Center', sortable: true }
], pager: jQuery('#pager'),
cmTemplate: { title: false },
width: widthValue - 15,
height: 435,
rowNum: 20,
rowList: [20, 30, 40, 50, 60],
viewrecords: true,
gridComplete: loadCompleteFunction,
altRows: true,
sortorder: 'desc',
sortname: 'Number',
sortable: true,
onSortCol: function (index, idxcol, sortorder) {
if (this.p.lastsort >= 0 && this.p.lastsort !== idxcol
&& this.p.colModel[this.p.lastsort].sortable !== false) {
$(this.grid.headers[this.p.lastsort].el).find(">div.ui-jqgrid-sortable>span.s-ico").show();
}
}
,
onSelectRow: showMessageDetails,
postData: {
},
loadError: function (xml) { alert('Unable to load result data.'); }
});
//制御コード
[HttpPost]
public ActionResult GetSearchPositionResult(string sidx, string sord, int page, int rows)
{
_Object = new PositionModel();
_Object.CurrentPage = page;
_Object.PageRowCount = rows;
_Object.load();
var result = new
{
total = _Object.TotalPages,
page = page,
sort = sidx,
sord = sord,
records = _Object.TotalRows,
rows = _ObjectPM.SearchResult.Select(p => new
{
cell = new string[]{
p.Number,
p.Unit
},sidx
}).OrderBy(a => a.sidx).ToArray(), };
return Json(result, JsonRequestBehavior.AllowGet);
}