setColumnHidden 구현

4916 단어 hidden

 
/**  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 = "";
  };
}
 

  
 
  this.rowsBuffer = dhtmlxArray();
  this.rowsCol = dhtmlxArray();
  /**  -  by 20140814 **/
  this.colHiddenArr = {};

 
 
  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
  };

 
 
  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]);

    }
  };

 
 
 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();
  },

  
 
  
  _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 = "&nbsp;";
        r.childNodes[i]._clearCell = true
      }
    };
    return r
  },

 
 
 
API 호출

setColumnHidden(ind, state)


ind - column index

state - true/false - hide/show column

좋은 웹페이지 즐겨찾기