datagrid制作动态表头

// 初始表格

$('#dg').datagrid({  

         //height : 370,  

        //pageSize : 11,// 默认选择的分页是每页10行数据
       // pageList : [  11, 16, 21 ],// 可以选择的分页集合
        nowrap : true,// 设置为true,当数据长度超出列宽时将会自动截取
        striped : true,// 设置为true将交替显示行背景。
        url:'processController/getProcessCostDifference.do',// url调用Action方法
        loadMsg : '数据装载中......',  
        singleSelect:false,//为true时只能选择单行 为了实现批量删除必须隐去
        selectOnCheck: true,
checkOnSelect:true,
        fitColumns:true,// 允许表格自动缩放,以适应父容器
        //pagination : true,// 分页
        rownumbers : true,// 行数 .
        columns : [
                   [{title:'热卷工序成本差异分析',colspan:8}],
                   [{field:'elmtGroupName',title:"",width:50},
            {field:'LastMonthAmount',title:"上月实际(元)",width:50},
            {field:'currentMonthAmount',title:"当月实际(元)",width:50},
            {field:'costDifference', title:"",width:50},
            {field:'priceImpact',title:"",width:50},
            {field:'consumeImpact',title:"",width:50},
            {field:'scopeImpact',title:"",width:50},
            {field:'costImpact',title:"",width:50},
            ]],
        onLoadSuccess : function(data){
        $(this).datagrid('resize');
        }

    });



//触发表头修改的方法
function sear() {
if($('#searchForm').form('validate')){
var productName =  $.trim($('#productName').val());
var currentMonthlyTime=  $('#currentMonthlyTime').datebox('getValue');
setTitle();
$('#dg').datagrid({
queryParams:{productName : productName,currentMonthlyTime:currentMonthlyTime}
});

}
}

//修改表头的方法

function  setTitle(){

var currentMonthlyTime=  $('#currentMonthlyTime').datebox('getValue');
var timeStr = currentMonthlyTime.split("-");
var month = parseInt(timeStr[1]);
var lastMonth = month - 1;

if(month == 1){
lastMonth = 12;
}
var option = $('#dg').datagrid("getColumnOption","LastMonthAmount");
var option1 = $('#dg').datagrid("getColumnOption","currentMonthAmount");
    option.title=lastMonth + "月实际(元)";
    option1.title=month + "月实际(元)";
}

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值