jqGrid datecolumn 不排序
jqGrid datecolumn not sorting
一直在 Whosebug 中寻找答案,但到目前为止没有任何效果。目前顺序是完全随机的。但我需要它才能排序。传入日期的格式为 2017-01-13 12:30:34.314。无论如何我都无法解决它。
使用 jqgrid 4.5.2
{name:'tahtaeg', width: 25, classes: 'textAlignAsBox', title: false, resizable: true,
date: true, editable: vvj||strj,
editoptions:{
dataInit: function(element){
jQuery(element).datepicker({
dateFormat: sos.kvp.i18n.dateFormat.dateTimePicker,
mindate: 0,
showHour: false,
showMinute: false,
showTime: false,
alwaysSetTime: false,
showButtonPanel: false,
onSelect:function(){
jQuery(this).datepicker("hide");
jqGridTegevused.jqGrid('saveCell',row,col);
}
});
}
},
sorttype:'date',
formatter: 'date',
formatoptions: {newformat:'d.m.Y'},
editrules: {custom: true, custom_func: globalKvp.util.jqGridValidateDate}
},
datatype: 'json',
cellEdit: true,
sortable:true,
loadonec: true,
cellsubmit: 'clientArray',
restoreAfterSelect: false,
saveAfterSelect: true,
editurl: 'clientArray',
autowidth: true,
sortname: 'tahtaeg',
sortorder: 'desc',
scrollOffset: 0,
height: '100%',
viewrecords: true,
rownumbers: false,
hidegrid: false,
caption: "",
loadui: "disable",
altRows:true,
altclass: 'ui-jqgrid-alternate',
您的代码使用 loadonec: true
而不是 loadonce: true
。这似乎是一个打字错误。结果 jqGrid 假设 服务器端 排序、分页和 filtering/searching。如果用户单击某个列的 header 列,则网格将按排序顺序从服务器重新加载,return 是服务器。
顺便说一句,您使用 sortname: 'tahtaeg'
和 sortorder: 'desc'
。这意味着服务器必须 return 正确排序 来自服务器的初始数据。
我不建议你使用复古版本 4.5.2(它已经快 4 岁了),它已经过时了,而且已经有几年不受支持了。我建议你升级到 free jqGrid 4.13.6, which you can download from GitHub or to load all the files directly from CDN (see the wiki article).
升级到免费的 jqGrid 后,您将拥有更好的性能,并且可以使用许多新功能,例如,新选项 forceClientSorting: true
,这将使 客户端排序和过滤 最初加载的数据。我建议您另外使用 Font Awesome 4.7 图标,而不是旧的 jQuery UI 图标。您只需要包含 Font Awesome CSS 并添加 iconSet: "fontAwesome"
选项。有关代码示例,请参阅 here。
一直在 Whosebug 中寻找答案,但到目前为止没有任何效果。目前顺序是完全随机的。但我需要它才能排序。传入日期的格式为 2017-01-13 12:30:34.314。无论如何我都无法解决它。
使用 jqgrid 4.5.2
{name:'tahtaeg', width: 25, classes: 'textAlignAsBox', title: false, resizable: true,
date: true, editable: vvj||strj,
editoptions:{
dataInit: function(element){
jQuery(element).datepicker({
dateFormat: sos.kvp.i18n.dateFormat.dateTimePicker,
mindate: 0,
showHour: false,
showMinute: false,
showTime: false,
alwaysSetTime: false,
showButtonPanel: false,
onSelect:function(){
jQuery(this).datepicker("hide");
jqGridTegevused.jqGrid('saveCell',row,col);
}
});
}
},
sorttype:'date',
formatter: 'date',
formatoptions: {newformat:'d.m.Y'},
editrules: {custom: true, custom_func: globalKvp.util.jqGridValidateDate}
},
datatype: 'json',
cellEdit: true,
sortable:true,
loadonec: true,
cellsubmit: 'clientArray',
restoreAfterSelect: false,
saveAfterSelect: true,
editurl: 'clientArray',
autowidth: true,
sortname: 'tahtaeg',
sortorder: 'desc',
scrollOffset: 0,
height: '100%',
viewrecords: true,
rownumbers: false,
hidegrid: false,
caption: "",
loadui: "disable",
altRows:true,
altclass: 'ui-jqgrid-alternate',
您的代码使用 loadonec: true
而不是 loadonce: true
。这似乎是一个打字错误。结果 jqGrid 假设 服务器端 排序、分页和 filtering/searching。如果用户单击某个列的 header 列,则网格将按排序顺序从服务器重新加载,return 是服务器。
顺便说一句,您使用 sortname: 'tahtaeg'
和 sortorder: 'desc'
。这意味着服务器必须 return 正确排序 来自服务器的初始数据。
我不建议你使用复古版本 4.5.2(它已经快 4 岁了),它已经过时了,而且已经有几年不受支持了。我建议你升级到 free jqGrid 4.13.6, which you can download from GitHub or to load all the files directly from CDN (see the wiki article).
升级到免费的 jqGrid 后,您将拥有更好的性能,并且可以使用许多新功能,例如,新选项 forceClientSorting: true
,这将使 客户端排序和过滤 最初加载的数据。我建议您另外使用 Font Awesome 4.7 图标,而不是旧的 jQuery UI 图标。您只需要包含 Font Awesome CSS 并添加 iconSet: "fontAwesome"
选项。有关代码示例,请参阅 here。