我正在使用动态列绑定绑定jqgrid但是通过以下操作我没有得到SortColumn或sidx。 但是,当我尝试使用静态列绑定时,它工作正常。 我的jqgrid绑定代码是
jQuery("#dataList").jqGrid({
url: gridDataUrl,
datatype: "json",
colNames: columnNames,
colModel: colModel,
autowidth: true,
width: 'auto',
height: 'auto',
rowNum: 10,
rowList: [10, 20, 30],
scrolling: false,
shrinktofit: true,
pager: '#pager',
// scrollrows: true,
sortname: 'Name',
rownumbers: false,
rownumWidth: 30,
viewrecords: true,
sortorder: "aesc",
multiselect: false,
imgpath: gridimgpath,
editurl: "/Admin/PerformCRUDAction" + "?lookupId=" + $('#LookUp').val(),
inlineData: {
jsondata: function () {
var selRowId = $("#dataList").jqGrid('getGridParam', 'selrow');
getActualRowData(selRowId);
var jsonOfLog = JSON.stringify(myKeyValuePairs);
return jsonOfLog;
}
},
onSelectRow: null
}).navGrid("#pager",
{ refresh: false, add: false, edit: false, del: false, search: false },
{}, // settings for edit
{}, // settings for add
{}, // settings for delete
{} // Search options. Some options can be set on column level
);
来自ajax调用的列模型是
var colModel= [
{ index: 'Id', name: 'Id', align: 'center', 'hidden': true, editable: false },
{ index: 'Value', name: 'Value', align: 'center', editable: true, editrules: { custom: true, custom_func: myvaluecheck } },
{ index: 'Name', name: 'Name', align: 'center', editable: true, editrules: { custom: true, custom_func: CheckName } },
{
name: 'myac', width: 80, fixed: true, sortable: false, resize: false, formatter: 'actions',
formatoptions: {
keys: true,
onEdit: null,
onSuccess: null,
onError: null,
afterSave: null,
afterRestore: null,
delOptions: {
onclickSubmit: function (rp_ge, rowid) {
var selRowId = $('#dataList').jqGrid('getGridParam', 'selrow');
var celValue = $('#dataList').jqGrid('getCell', selRowId, 'Id');
Delete(celValue);
debugger;
rp_ge.processing = true;
$("#dataList").delRowData(rowid);
$("#delmod" + grid[0].id).hide();
if (grid[0].p.lastpage > 1) {
grid.trigger("reloadGrid", [{ page: grid[0].p.page }]);
}
return true;
},
processing: true
}
}
}
服务器端的代码是
public JsonResult GetGridData(GridSettings gridSettings,string sord,string sidx)
{}
答案 0 :(得分:0)
也许,当点击任何按钮进行排序时,您需要检索键值数组,对其进行排序并重新绑定数据网格。
以下是一个例子: