我已经看到了关于这个问题的许多变化,并且我尝试使用所有知识,但仍然没有运气。
我的日期从旧到新排序,我想将它们从新到旧排序。
在您看到 desc 的地方,我尝试过 asc,但没有任何变化。
当我尝试分页时,似乎触发了重新加载,并且排序正确,从新到旧。
将重新加载设置为 1 秒并清除间隔的最佳解决方案是什么?还是我有其他问题?
我无法对服务器端进行排序,这不是一个选择。
$("#transactionList").jqGrid({
url: "/cc/transaction/show/"+accountId,
datatype: "local",
autowidth: true,
height: 'auto',
sortname: 'tran_date',
sortorder: 'desc',
sortable:true,
loadonce:true,
viewrecords: true,
gridview: true,
firstsortorder: 'desc',
colNames:['Date','Asset Name','Description','Amount','Actions'],
colModel:[
{name:'tran_date',index:'tran_date',sorttype:'date',sortable:true,formatter:'date',firstsororder: 'desc',datefmt: 'M d,Y',formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'M d,Y'}},
{name:'assname',index:'assname',sortable:true,resizable:false},
{name:'desccription',index:'desccription',sortable:true,resizable:false},
{name:'net_proc', index:'net_proc',align:'right',formatter:'currency',formatoptions{decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "$", defaultValue:'0.00'}, sortable:true,resizable:false}, {name:'ID',index:'ID',formatter:actionsFormatter,width:130,align:"center",key:true,resizable:false}
],
caption: "Completed Transactions",
rowTotal: -1,
rowNum: 1000,
rowList: [10,20,30],
pager: '#pager',
onSelectRow: function(row_id) {
},
jsonReader: {
repeatitems: false,
id: "ID",
userdata: 'rows'
},
viewrecords: true,
gridComplete: function() {
//Attach action event handlers
$('span[name="details"]').click(function() {
var row_id = this.id;
var data = $("#transactionList").getGridParam('userData');
var rowData;
$.each(data, function(index,el){
if(el.ID==row_id)
rowData = el;
});
var message = '<div class="sectionItem"><span class="label">Asset Name: </span><span class="value">'+rowData.assname+rowData.assname2+'</span></div>';
message += '<div class="sectionItem"><span class="label">Amount: </span><span class="value">'+rowData.net_proc+'</span></div>';
message += '<div class="sectionItem"><span class="label">Transaction Date: </span><span class="value">'+rowData.tran_date+'</span></div>';
$.popMessage('Transactions Details', message);
}).addToolTip('Details');
}
})
$("#transactionList").setGridParam({datatype: 'json'}).trigger("reloadGrid");
;