jqgrid colModel 中formatter的用法

 

var historys = function()
{
 function format( cellvalue){  //cellvalue表示当前单元格的值
  var str = "";
        var hour = 0;
        var minute = 0;
        var second = 0;

        second = cellvalue / 1000;

        if (second > 60) {
            minute = second / 60;
            second = second % 60;
        }
        if (minute > 60) {
            hour = minute / 60;
            minute = minute % 60;
        }
       
        var strHour = parseInt(hour);
        var strMinute = parseInt(minute); 
        var strSecond = parseInt(second);
       
        return (strHour + "小时" + strMinute + "分钟"
                + strSecond + "秒");
 }
 
 
 /**加载数据列表*/
 /**加载数据列表*/
 this.load_processHistories_list=function()
 {
  $("#historyProcess").jqGrid({ 
   url:'upload!showHistories.action',
   mtype:"post",
   datatype:"json",         
   height:250,width:850,
   colNames:['Key','ProcessID','InstanceID','state','startTime','endTime','Duration','endActivityName'],
   colModel:[
       {name:'key',index:'key',width:50,sorttype:'Long',sortable:true,editable:true},
       {name:'processDefinitionId',index:'processDefinitionId',width:100,editable:true},
       {name:'processInstanceId',index:'processInstanceId',width:100,align:'center',editable:true},
       {name:'state',index:'state',width:50,sortable:false,align:'center',editable:true},
       {name:'startTime',index:'startTime',width:100,align:'center',editable:true},
       {name:'endTime',index:'endTime',width:100,sortable:false,align:'center',editable:true},
       {name:'duration',index:'duration',width:100,align:'center',editable:true,formatter:format},
       {name:'endActivityName',index:'endActivityName',width:150,sortable:false,align:'center',editable:true}
      ],
   pager:'#page',
   rowNum:10,
   rowList:[10,15,20,30],
   viewrecords: true,
   multiselect:true,
   sortname:'imId',
   sortorder:'desc',
   editurl:'eidt.do',
   caption:'  流程管理',
   jsonReader: {
    root: "histories",
    records: "records",
    page: "page",
    total: "total",
    repeatitems: false,
    id: "imId"
   },
   toolbar: [true,"top"],
    
  });

   
   $("#t_historyProcess")
   .css("padding-top","5px")
   .css("padding-bottom","10px")
   .css("border-top","none")
   .css("background","#eee")
   .css("text-align","left");
   
   $("#t_historyProcess").append($('#toolbar').html());

   jQuery("#historyProcess") .navGrid('#page',{edit:false,add:false,del:false,search:false});

 
 }
 /**open the search window*/
 this.search_openwindow=function()
 {  
  $('#searchProcess').window('open');
 }

 /**close the search window*/
 this.search_closewindow=function()
 {  
  $('#searchProcess').window('close');
 }
  //载入
  return {
  init: function()
  {
   //加载数据列表
          load_processHistories_list();
          $('#link_search_ok').click(search_openwindow);
    $('#link_search_cancel').click(search_closewindow); 
  }
 }
 
}();

 

//载入
$(document).ready(function()
{
 historys.init();
});

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值