需要注意:
因爲兼容問題使用jquery的hide
hide()在IE下改變了表結構,導致獲得的cellIndex不準確
改變寬度高度爲0的試了,不可以
$(function(){
var isCleanList = $("[id$='isCleanList']").val();
if(isCleanList == '1'){ //查詢已清理賬戶
}else{ // 查詢未清理賬戶
hideColByObj($("[id$='feedbackDateLab']")[1]); //處理日期 注意順序
hideColByObj($("[id$='undoReasonLab']")[1]); //不處理原因
hideColByObj($("[id$='feedbackResultLab']")[1]); //反饋結果
}
});
/**
* 隱藏某一列
* @param oTable 表格dom對象
* @param iCol 列號
*/
function hideColByIndex(oTable, iCol) {
for (i = 0; i < oTable.rows.length; i++) {
//用jquery的hide()效果更好
//oTable.rows[i].cells[iCol].style.display = oTable.rows[i].cells[iCol].style.display == "none" ? "block" : "none";
$(oTable.rows[i].cells[iCol]).hide(); //注意IE下調用hide方法會改變表結構,不能正確獲得cellIndex,所以應該從後向前隱藏
}
}
/**
* 隱藏某一列
* @param oTable 表格dom對象
* @param colName 列名
*/
function hideColByObj(obj) {
var otd = nstc.sf.findParent(obj, "TH");
var cellIndex = otd.cellIndex;
var otable = nstc.sf.findParent(otd, "TABLE");
hideColByIndex(otable, cellIndex);
}