{name:'starttime',index:'starttime', width:160,edittype:"date", unformat: pickDate,editrules:{required:true},},
//enable datepicker
function pickDate( cellvalue, options, cell ) {
setTimeout(function(){
$(cell) .find('input[type=text]')
.datepicker({format:'yyyy-MM-dd HH:mm:ss' , autoclose:true});
}, 0);
}
在此处引用pickDate方法,将返回的毫秒值转换成相应的yyyy-MM-dd HH:mm:ss 格式显示在页面上
{name:'starttime',index:'starttime', width:160,edittype:"date", formatter:resultFormatter,,editrules:{required:true},},
function getzf(num){
if(parseInt(num) < 10){
num = '0'+num;
}
return num;
}
function resultFormatter(cellvalue, timestamp, rowObject){
var oDate = new Date(cellvalue),
oYear = oDate.getFullYear(),
oMonth = oDate.getMonth()+1,
oDay = oDate.getDate(),
oHour = oDate.getHours(),
oMin = oDate.getMinutes(),
oSen = oDate.getSeconds(),
oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);//最后拼接时间
return oTime;
}
这是将传递回来的毫秒值通过计算并且拼接成固定格式返回给页面
目前我用的是这两种方式展示时间,其他的会遇到之后会逐步添加至此。
标红的部分是设置搜索的格式,这个时候引入的js是
其他的搜索功能例如:{name:'content',index:'content', editable: true,hidden:true,search: true,editrules:{edithidden:true},edittype:"text",sortable:false,
formoptions:{elmsuffix:"*"},editoptions:{size:"20",maxlength:"30"},stype:"text",searchoptions:{searchhidden:true}},
{name:'lineid',index:'lineid', width:90, sortable:false,editable: true,edittype:"select",formatter:lineResult,
editoptions:{value:":请选择;" + getLine()},stype:"select",searchoptions:{value:":请选择;" + getLine()}},
{name:'linetype',index:'linetype', width:60, sortable:false,editable: true,edittype:"select",editrules:{required:true},formatter:linetypeResult,
editoptions:{value:":请选择;1:单;2:双"},stype:"select",searchoptions:{value:":请选择;1:单;2:双"}},