文章来自 codego.net 请看源代码:
$(function(){
$('#tt').datagrid({
title:'报表统计',
width:1020,
height:400,
url:'',
fitColumns:true,
loadMsg:'正在获取,请稍侯...',
singleSelect:true,
nowrap:false,
columns:[[
{field:'REGION_NAME',title:'分公司',width:30,align:'center'},
{field:'COUNTY_NAME',title:'区县',width:80,align:'center',editor:'text'},
{field:'AREA_NAME',title:'网格',width:80,align:'center',editor:'text'},
{field:'ORG_NAME',title:'网点',width:80,align:'center'},
{field:'TOTAL_NUM',title:'总业务量',width:40,align:'center'},
{field:'DH_NUM',title:'单宽业务量',width:40,align:'center'},
{field:'RH_NUM',title:'融合业务量',width:40,align:'center'},
{field:'YYT_NUM',title:'营业厅业务量',width:40,align:'center'},
{field:'QT_NUM',title:'其他业务量',width:40,align:'center'}
]],
toolbar:[
],
onDblClickRow: function() {
//selected = $('#tt').datagrid('getSelected');
//var index = $('#tt').datagrid('getRowIndex', selected);
//$('#tt').datagrid('beginEdit', index);
//progress();
//taskPreempte(selected.taskId);
}
});
$('#my_toolbar').appendTo('.datagrid-toolbar');
var dd = new Date();
var d1 = dd.getFullYear()+ "-" + (dd.getMonth()+1) + "-1" ;
var d2 = dd.getFullYear() + "-" + (dd.getMonth()+1) + "-" + dd.getDate() ;
$('#qryStartDate').datebox('setValue', d1); // set datebox value
$('#qryEndDate').datebox('setValue', d2); // set datebox value
refreshRpt2();
});
function refreshRpt2(){
var strStatCond = "b.region_name";
if($('#qryCon').attr("value")!=100){
param.sts = $('#qryCon').attr("value");
alert(param.sts);
}
param.qryBeginTime =$('#qryStartDate').datebox('getValue');
//alert(param.qryBeginTime);
param.qryEndTime = $('#qryEndDate').datebox('getValue');
//alert(param.qryEndTime);
if($('#region')!= null && $('#region').attr("checked") == true){
}
if($('#county')!= null && $('#county').attr("checked") == true){
strStatCond += ",c.county_name";
$('#tt').datagrid('showColumn', 'COUNTY_NAME');
}else{
$('#tt').datagrid('hideColumn', 'COUNTY_NAME');
}
if($('#area')!= null && $('#area').attr("checked") == true){
strStatCond += ",d.area_name";
$('#tt').datagrid('showColumn', 'AREA_NAME');
}else{
$('#tt').datagrid('hideColumn', 'AREA_NAME');
}
if($('#org')!= null && $('#org').attr("checked") == true){
strStatCond += ",e.org_name";
$('#tt').datagrid('showColumn', 'ORG_NAME');
}else{
$('#tt').datagrid('hideColumn', 'ORG_NAME');
}
alert(strStatCond);
param.statCond = strStatCond;
param.rptName = "statBusiRpt";
JSBaseCall.execute(param,showResult2);
}
//显示记录集
function showResult2(data){
var strJson=data["defaultJsonString"];
var result=eval('(' + strJson + ')');
//alert(strJson);
if (result.KEY_JSCALL_RESULT){
if (result.KEY_SERVICE_RES){//成功
totalRec=result.KEY_TOTAL_REC;
var d={"total":pageShowRec,
"rows":result.defaultAList
};
$('#tt').datagrid('loadData',d);
}
}
}
比如在“曲县”没数据时表格就不用显示空列了,而是直接将这一列隐藏掉
网站栏目:jQuery动态显示和隐藏datagrid中的某一列的方法
本文URL:
http://cdxtjz.cn/article/jgocgc.html