DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> jQuery動態顯示和隱藏datagrid中的某一列的方法
jQuery動態顯示和隱藏datagrid中的某一列的方法
編輯:JQuery特效代碼     
. 代碼如下:
$(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);
}
}
}

比如在“曲縣”沒數據時表格就不用顯示空列了,而是直接將這一列隱藏掉
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved