我的日期格式为MM/DD/YYYY
,但它们没有以正确的格式排序。它添加了垃圾数据。
function loadGrid()
{
$("#grid").jqGrid({
datatype: "local",
altRows: true,
altclass: 'myAltRowClass',
colNames:['Expense # ', 'Description', 'Expense Date ', 'Amount ', 'Status '],
colModel:[
{name:'expno',index:'expno', width:80, align:"center",sorttype:"string"},
{name:'desc',index:'desc', width:150, align:"center",sortable:false},
{name:'expdate',index:'expdate', align:"center",width:80, sorttype:'date',formatter:'date', formatoptions: {newformat:'mm/dd/yyyy'}, datefmt: 'mm-dd-yyyy'},
{name:'expamnt',index:'expamnt',align:"left", width:70,sortable:false},
{name:'estatus',index:'estatus', width:90, align:"center",sortable:false},
],
beforeSelectRow: function(rowid, e) { return false;},
hidegrid: false,
height: "auto",
width: "700",
multiselect: false,
caption: "My Expenses",
rowList:[10,20,30],
rowNum: 10,
page: 1,
pager: '#pager',
viewrecords: true,
sortname:'expno',
sortorder: 'asc',
loadComplete: function () {
$( ".selector" ).button({});
$("#grid").effect("highlight", {}, 1500);
}
});
for(var i=0;i<=gridData.length;i++)
jQuery("#grid").jqGrid('addRowData',i + 1, gridData[i]);
jQuery("#grid").setGridParam({rowNum:10}).trigger("reloadGrid");
}
在这个函数之后,网格加载了 10 条记录。我想使用日期对这些记录进行排序。但是,我无法按照我在datefmt
选项中尝试的正确顺序进行排序。