easyui datagrid自定义表头

第一种实现方法:

实现界面:


html代码:

<table id="tt" class="easyui-treegrid" style="width:1000px;"></table>

js代码:

$('#tt').treegrid({
				url: '/cost/getInfo.do',
				method: 'get',
				queryParams:{year:y},
				autoRowHeight:true,
				animate:true,
				lines:true,
				height:425,
				fitColumns:true,
				idField: 'subjectId',
				treeField: 'subjectName',
				onLoadSuccess: function () { $('#tt').treegrid('collapseAll'); },
				 columns:[[
				{field:'subjectName',title:'科目名称',width:220,align:'left',styler:function(){return 'height:30px;';}},
				{field:'realTotal',title:real_Budget,width:200,align:'right'},
			    <span style="white-space:pre">	</span>{field:'planTotal',title:plan_Budget,width:200,align:'right'},
				{field:'completeRate',title:'达成率',width:200,align:'right'}
				
				
		    ]]
		});

第二种方法:

实现界面


html代码:

<table id="reportDetail" class="easyui-treegrid" style="width:1000px;"
                   data-options="url:'/report/searchReportDetail.do',idField:'subjectId',treeField:'subject'">
               <thead>
                   <tr>
                       <th rowspan="2" data-options="field:'subject',width:150,align:'left',styler:function(){return 'height:30px;';}">科目</th>
                       <th colspan="3" data-options="width:300,align:'right'">$query.month月</th>
                       <th colspan="3" data-options="width:300,align:'right'" class="querymonth">YTD累计1-$query.month月</th>
                       <th colspan="2" data-options="width:240,align:'right'">FY年度</th>
                   </tr>
                   <tr >
                       <th data-options="field:'actualMonth',width:100,align:'right'">实际</th>
                       <th data-options="field:'budgetMonth',width:100,align:'right'">预算</th>
                       <th data-options="field:'budgetAchieveRate',width:100,align:'right'">预算达成率(%)</th>
                       <th data-options="field:'ytdActualMonth',width:100,align:'right'">实际</th>
                       <th data-options="field:'ytdBudgetMonth',width:100,align:'right'">预算</th>
                       <th data-options="field:'ytdBudgetAchieveRate',width:100,align:'right'">预算达成率(%)</th>
                       <th data-options="field:'fyBudget',width:118,align:'right'">预算</th>
                       <th data-options="field:'fyBudgetAchieveRate',width:118,align:'right'">预算达成率(%)</th>
                   </tr>
               </thead>
            </table>

js代码:

$('#reportDetail').treegrid({
            url: '/AAAA/BBB.do',
            method: 'get',
            queryParams:{year:y,month:m,deptTwo:t},
            autoRowHeight:true,
            animate:true,
            lines:true,
            height:425,
            idField: 'subjectId',
            treeField: 'subject',
            onLoadSuccess: function () {
                $('#reportDetail').treegrid('collapseAll');
                $("table.datagrid-htable tr:eq(0) td:eq(1) .datagrid-cell-group").text(m+"月");
                $("table.datagrid-htable tr:eq(0) td:eq(2) .datagrid-cell-group").text("YTD累计1-"+m+"月");
            }

        });


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值