dhtmlxGrid实现setColumnHidden
2016-03-22 10:43
591 查看
Java代码
/** 设置TD隐藏或显示 by 20140814 **/
function cellHidden(cell, state) {
if ((state) && (cell.style.display != "none")) {
cell.style.display = "none";
};
if ((!state) && (cell.style.display == "none")) {
cell.style.display = "";
};
}
Js代码
this.rowsBuffer = dhtmlxArray();
this.rowsCol = dhtmlxArray();
/** 列是否隐藏-数组 by 20140814 **/
this.colHiddenArr = {};
Js代码
this.setColumnSizes = function(gridWidth) {
var summ = 0;
var fcols = [];
for (var i = 0; i < this._cCount; i++) {
if ((this.initCellWidth[i] == "*") && !this._hrrar[i]) {
this._awdth = false;
fcols.push(i);
continue
};
if (this.cellWidthType == '%') {
if (typeof this.cellWidthPC[i] == "undefined")
this.cellWidthPC[i] = this.initCellWidth[i];
this.cellWidthPX[i] = Math.floor(gridWidth * this.cellWidthPC[i] / 100) || 0
} else {
if (typeof this.cellWidthPX[i] == "undefined")
this.cellWidthPX[i] = this.initCellWidth[i]
};
/** 计算列总宽度时,忽略隐藏列 by 20140814 **/
if (!this._hrrar[i] && !this.colHiddenArr[i])
summ += this.cellWidthPX[i] * 1
};
if (fcols.length) {
var ms = Math.floor((gridWidth - summ) / fcols.length);
if (ms < 0)
ms = 1;
for (var i = 0; i < fcols.length; i++) {
var next = Math.max((this._drsclmW ? this._drsclmW[fcols[i]] : 0), ms)
this.cellWidthPX[fcols[i]] = next;
summ += next
};
this._setAutoResize()
};
this.obj.style.width = summ + "px";
this.hdr.style.width = summ + "px";
if (this.ftr)
this.ftr.style.width = summ + "px";
this.chngCellWidth();
return summ
};
Js代码
this.chngCellWidth = function() {
if ((_isOpera) && (this.ftr))
this.ftr.width = this.objBox.scrollWidth + "px";
var l = this._cCount;
for (var i = 0; i < l; i++) {
this.hdr.rows[0].cells[i].style.width = this.cellWidthPX[i] + "px";
this.obj.rows[0].childNodes[i].style.width = this.cellWidthPX[i] + "px";
if (this.ftr)
this.ftr.rows[0].cells[i].style.width = this.cellWidthPX[i] + "px"
/** 针对列表中已有数据和列,判断隐藏|显示 by 20140814 **/
cellHidden(this.hdr.rows[0].childNodes[i], this.colHiddenArr[i]);
cellHidden(this.obj.rows[0].childNodes[i], this.colHiddenArr[i]);
if (this.ftr)
cellHidden(this.ftr.rows[0].cells[i], this.colHiddenArr[i]);
}
};
Js代码
setRowHidden : function (id, state) {},
/** 设置列隐藏|显示 by qiugq 20140814 **/
setColumnHidden : function(cin, state) {
this.colHiddenArr[cin] = state;
var z = this.hdr.rows[1];
for (var i = 0; i < z.cells.length; i++) {
if (z.cells[i]._cellIndexS == cin) {
cellHidden(z.cells[i], state);
}
}
for (var i = 0; i < this.rowsBuffer.length; i++) {
var c = this.rowsBuffer[i];
var cell = (c._childIndexes ? c.childNodes[c._childIndexes[cin]] : c.childNodes[cin]);
cellHidden(cell, state);
}
this.setColumnSizes();
},
Java代码
_fillRow : function(r, text) {
if (this.editor)
this.editStop();
for (var i = 0; i < r.childNodes.length; i++) {
/** 加载数据时判断列是否隐藏 by 20140814 **/
cellHidden (r.childNodes[i], this.colHiddenArr[i])
if ((i < text.length) || (this.defVal[i])) {
var ii = r.childNodes[i]._cellIndex;
var val = text[ii];
var aeditor = this.cells4(r.childNodes[i]);
if ((this.defVal[ii]) && ((val == "") || (typeof(val) == "undefined")))
val = this.defVal[ii];
if (aeditor)
aeditor.setValue(val)
} else {
r.childNodes[i].innerHTML = " ";
r.childNodes[i]._clearCell = true
}
};
return r
},
调用API
ind - column index
state - true/false - hide/show column
/** 设置TD隐藏或显示 by 20140814 **/
function cellHidden(cell, state) {
if ((state) && (cell.style.display != "none")) {
cell.style.display = "none";
};
if ((!state) && (cell.style.display == "none")) {
cell.style.display = "";
};
}
Js代码
this.rowsBuffer = dhtmlxArray();
this.rowsCol = dhtmlxArray();
/** 列是否隐藏-数组 by 20140814 **/
this.colHiddenArr = {};
Js代码
this.setColumnSizes = function(gridWidth) {
var summ = 0;
var fcols = [];
for (var i = 0; i < this._cCount; i++) {
if ((this.initCellWidth[i] == "*") && !this._hrrar[i]) {
this._awdth = false;
fcols.push(i);
continue
};
if (this.cellWidthType == '%') {
if (typeof this.cellWidthPC[i] == "undefined")
this.cellWidthPC[i] = this.initCellWidth[i];
this.cellWidthPX[i] = Math.floor(gridWidth * this.cellWidthPC[i] / 100) || 0
} else {
if (typeof this.cellWidthPX[i] == "undefined")
this.cellWidthPX[i] = this.initCellWidth[i]
};
/** 计算列总宽度时,忽略隐藏列 by 20140814 **/
if (!this._hrrar[i] && !this.colHiddenArr[i])
summ += this.cellWidthPX[i] * 1
};
if (fcols.length) {
var ms = Math.floor((gridWidth - summ) / fcols.length);
if (ms < 0)
ms = 1;
for (var i = 0; i < fcols.length; i++) {
var next = Math.max((this._drsclmW ? this._drsclmW[fcols[i]] : 0), ms)
this.cellWidthPX[fcols[i]] = next;
summ += next
};
this._setAutoResize()
};
this.obj.style.width = summ + "px";
this.hdr.style.width = summ + "px";
if (this.ftr)
this.ftr.style.width = summ + "px";
this.chngCellWidth();
return summ
};
Js代码
this.chngCellWidth = function() {
if ((_isOpera) && (this.ftr))
this.ftr.width = this.objBox.scrollWidth + "px";
var l = this._cCount;
for (var i = 0; i < l; i++) {
this.hdr.rows[0].cells[i].style.width = this.cellWidthPX[i] + "px";
this.obj.rows[0].childNodes[i].style.width = this.cellWidthPX[i] + "px";
if (this.ftr)
this.ftr.rows[0].cells[i].style.width = this.cellWidthPX[i] + "px"
/** 针对列表中已有数据和列,判断隐藏|显示 by 20140814 **/
cellHidden(this.hdr.rows[0].childNodes[i], this.colHiddenArr[i]);
cellHidden(this.obj.rows[0].childNodes[i], this.colHiddenArr[i]);
if (this.ftr)
cellHidden(this.ftr.rows[0].cells[i], this.colHiddenArr[i]);
}
};
Js代码
setRowHidden : function (id, state) {},
/** 设置列隐藏|显示 by qiugq 20140814 **/
setColumnHidden : function(cin, state) {
this.colHiddenArr[cin] = state;
var z = this.hdr.rows[1];
for (var i = 0; i < z.cells.length; i++) {
if (z.cells[i]._cellIndexS == cin) {
cellHidden(z.cells[i], state);
}
}
for (var i = 0; i < this.rowsBuffer.length; i++) {
var c = this.rowsBuffer[i];
var cell = (c._childIndexes ? c.childNodes[c._childIndexes[cin]] : c.childNodes[cin]);
cellHidden(cell, state);
}
this.setColumnSizes();
},
Java代码
_fillRow : function(r, text) {
if (this.editor)
this.editStop();
for (var i = 0; i < r.childNodes.length; i++) {
/** 加载数据时判断列是否隐藏 by 20140814 **/
cellHidden (r.childNodes[i], this.colHiddenArr[i])
if ((i < text.length) || (this.defVal[i])) {
var ii = r.childNodes[i]._cellIndex;
var val = text[ii];
var aeditor = this.cells4(r.childNodes[i]);
if ((this.defVal[ii]) && ((val == "") || (typeof(val) == "undefined")))
val = this.defVal[ii];
if (aeditor)
aeditor.setValue(val)
} else {
r.childNodes[i].innerHTML = " ";
r.childNodes[i]._clearCell = true
}
};
return r
},
调用API
setColumnHidden(ind, state)
ind - column indexstate - true/false - hide/show column
相关文章推荐
- HTML 特殊符号编码对照表
- HTML 表单(form) 使用详解
- HTML--1标签表格
- 腾讯实战案例!聊聊刷一刷红包预热HTML 5背后的设计过程
- HTML制作邮箱
- html 基础代码
- HTML
- 用lxml解析HTML
- list动画
- html 点击<a>元素后颜色的变换
- header(Content-Type:text/html;charset=GBK')
- 如何查看本地Git的html帮助文档
- 4款好用的开源HTML编辑器
- 异说html初学实战邮箱页面布局
- dhtmlxscheduler timeline
- 去除文本中的html代码 编辑器适用
- 礼拜一log:获取a标签隐藏属性的方法
- 使用HTML写一个简单的跳转登录页面
- HTML中的hash(#号)
- 作业:用HTML制作邮箱登陆界面