⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dhtmlxgrid.js

📁 dhtmlxGrid 是跨浏览器的 JavaScript 表格控制组件(Grid Control)
💻 JS
📖 第 1 页 / 共 5 页
字号:
 if(pNode == document.body){
 if(_isIE){
 if(document.documentElement.scrollTop)
 iTop+=document.documentElement.scrollTop;
 if(document.documentElement.scrollLeft)
 iLeft+=document.documentElement.scrollLeft;
}
 else
 if(!_isFF){
 iLeft+=document.body.offsetLeft;
 iTop+=document.body.offsetTop;
}
}
 return new Array(iLeft,iTop);
}
 
 this.getFirstParentOfType = function(obj,tag){
 while(obj.tagName!=tag && obj.tagName!="BODY"){
 obj = obj.parentNode;
}
 return obj;
}

 
 
 this.setColumnCount = function(cnt){alert('setColumnCount method deprecated')}
 
 this.showContent = function(){alert('showContent method deprecated')}

 
 this.objBox.onscroll = new Function("","this.grid._doOnScroll()")
 if((!_isOpera)||(_OperaRv>8.5))
{
 this.hdr.onmousemove = new Function("e","this.grid.changeCursorState(e||window.event)");
 this.hdr.onmousedown = new Function("e","this.grid.startColResize(e||window.event)");
}
 this.obj.onmousemove = this._drawTooltip;
 this.obj.onclick = new Function("e","this.grid._doClick(e||window.event);if(this.grid._sclE)this.grid.editCell(e||window.event);(e||event).cancelBubble=true;");
 this.entBox.onmousedown = new Function("e","return this.grid._doContClick(e||window.event);");
 this.obj.ondblclick = new Function("e","if(!this.grid.wasDblClicked(e||window.event)){return false};if(this.grid._dclE)this.grid.editCell(e||window.event);(e||event).cancelBubble=true;");
 this.hdr.onclick = this._onHeaderClick;
 this.hdr.ondblclick = this._onHeaderDblClick;

  if(!document.body._dhtmlxgrid_onkeydown){
 dhtmlxEvent(document,"keydown",new Function("e","if(globalActiveDHTMLGridObject)return globalActiveDHTMLGridObject.doKey(e||window.event);return true;"));
 document.body._dhtmlxgrid_onkeydown=true;
}

 dhtmlxEvent(document.body,"click",function(){if(self.editStop)self.editStop();return true;});

   this.entBox.onbeforeactivate = new Function("","this.grid.setActive();event.cancelBubble=true;");
 this.entBox.onbeforedeactivate = new Function("","this.grid.isActive=-1;event.cancelBubble=true;");
  this.doOnRowAdded = function(row){};
 return this;
}


 
 dhtmlXGridObject.prototype.isTreeGrid= function(){
 return(this.cellType._dhx_find("tree")!=-1);
}

 
 dhtmlXGridObject.prototype.addRow = function(new_id,text,ind){
 var r = this._addRow(new_id,text,ind);
 if(this.onRowAdded)
 this.onRowAdded(new_id);
 if(this.onRowCr)
 this.onRowCr(r.idd,r,null);
 if(this.pagingOn)
 this.changePage(this.currentPage)

 this.setSizes();
 return r;
}


 
 dhtmlXGridObject.prototype._prepareRow=function(new_id){
 var r=document.createElement("TR");
 r.idd = new_id;
 r.grid = this;

 for(var i=0;i<this.hdr.rows[0].cells.length;i++){
 var c = document.createElement("TD");
  if(this._enbCid)c.id="c_"+r.idd+"_"+i;
  c._cellIndex = i;
 if(this.dragAndDropOff)this.dragger.addDraggableItem(c,this);
 c.align = this.cellAlign[i];
 c.style.verticalAlign = this.cellVAlign[i];
  c.bgColor = this.columnColor[i] || "";




 r.appendChild(c);
}
 return r;
}
 
 dhtmlXGridObject.prototype._fillRow=function(r,text){
 if(!this._parsing_)this.editStop();

 this.math_off=true;
 this.math_req=false;

 if(typeof(text)!='object')
 text =(text||"").split(this.delim);
 for(var i=0;i<r.childNodes.length;i++){
 if((i<text.length)||(this.defVal[i])){
 var val = text[i]
 if((this.defVal[i])&&((val=="")||(val===window.undefined)))
 val = this.defVal[i];

 if(this._dload)
 this.editor = this.cells3(r,r.childNodes[i]._cellIndex);
 else
 this.editor = this.cells4(r.childNodes[i]);

  this.editor.setValue(val)
 this.editor = this.editor.destructor();
}else{
 var val = "&nbsp;";
 r.childNodes[i].innerHTML = val;
 r.childNodes[i]._clearCell=true;
}
}
 this.math_off=false;
 if((this.math_req)&&(!this._parsing_)){
 for(var i=0;i<this.hdr.rows[0].cells.length;i++)
 this._checkSCL(r.childNodes[i]);
 this.math_req=false;
}
 return r;
}

 
 dhtmlXGridObject.prototype._insertRowAt=function(r,ind,skip){
 if(ind<0)ind=this.rowsCol.length;

 if((arguments.length<2)||(ind===window.undefined))
 ind = this.rowsCol.length  else{
 if(ind>this.rowsCol.length)
 ind = this.rowsCol.length;
}

 if(!skip)
 if((ind==(this.obj.rows.length-1))||(!this.rowsCol[ind]))
 if(_isKHTML)
 this.obj.appendChild(r);
 else{
 this.obj.firstChild.appendChild(r);
}
 else
{
 this.rowsCol[ind].parentNode.insertBefore(r,this.rowsCol[ind]);
}


 this.rowsAr[r.idd] = r;
 this.rowsCol._dhx_insertAt(ind,r);

 if(this._cssEven){
 if(ind%2==1)r.className+=" "+this._cssUnEven;
 else r.className+=" "+this._cssEven;

 if(ind!=(this.rowsCol.length-1))
 this._fixAlterCss(ind+1);
}

  this.doOnRowAdded(r);

  if((this.math_req)&&(!this._parsing_)){
 for(var i=0;i<this.hdr.rows[0].cells.length;i++)
 this._checkSCL(r.childNodes[i]);
 this.math_req=false;
}

 return r;
}

 
 dhtmlXGridObject.prototype._addRow = function(new_id,text,ind){
 var row = this._fillRow(this._prepareRow(new_id),text);
 if(ind>this.rowsCol.length && ind<(this.rowsCol.length+this.rowsBuffer[0].length)){
 var inBufInd = ind - this.rowsCol.length;
 this.rowsBuffer[0]._dhx_insertAt(inBufInd,new_id);
 this.rowsBuffer[1]._dhx_insertAt(inBufInd,row);
 return row;
}
 return this._insertRowAt(row,ind);
}

 
dhtmlXGridObject.prototype.setRowHidden=function(id,state){
 var f=convertStringToBoolean(state);
    var row= this.getRowById(id) if(!row)
 return;

 if(row.expand==="")
 this.collapseKids(row);

 if((state)&&(row.style.display!="none")){
 row.style.display="none";
 var z=this.selectedRows._dhx_find(row);
 if(z!=-1){
 row.className=row.className.replace("rowselected","");
 for(var i=0;i<row.childNodes.length;i++)
 row.childNodes[i].className=row.childNodes[i].className.replace(/cellselected/g,"");
 this.selectedRows._dhx_removeAt(z);
}
 if(this.onGridReconstructed)
 this.onGridReconstructed();
}

 if((!state)&&(row.style.display=="none")){
 row.style.display="";
 if(this.onGridReconstructed)this.onGridReconstructed();
}

}


 
dhtmlXGridObject.prototype.enableRowsHover = function(mode,cssClass){
 this._hvrCss=cssClass;
 if(convertStringToBoolean(mode)){
 if(!this._elmnh){
 this.obj._honmousemove=this.obj.onmousemove;
 this.obj.onmousemove=this._setRowHover;
 if(_isIE)
 this.obj.onmouseleave=this._unsetRowHover;
 else
 this.obj.onmouseout=this._unsetRowHover;

 this._elmnh=true;
}
}else{
 if(this._elmnh){
 this.obj.onmousemove=this.obj._honmousemove;
 if(_isIE)
 this.obj.onmouseleave=null;
 else
 this.obj.onmouseout=null;

 this._elmnh=false;
}
}
};

 
dhtmlXGridObject.prototype.enableEditEvents = function(click,dblclick,f2Key){
 this._sclE = convertStringToBoolean(click);
 this._dclE = convertStringToBoolean(dblclick);
 this._f2kE = convertStringToBoolean(f2Key);
}


 
dhtmlXGridObject.prototype.enableLightMouseNavigation = function(mode){
 if(convertStringToBoolean(mode)){
 if(!this._elmn){
 this.entBox._onclick=this.entBox.onclick;
 this.entBox.onclick = function(){return true;};

 this.obj.onclick=function(e){
 var c = this.grid.getFirstParentOfType(e?e.target:event.srcElement,'TD');
 this.grid.editStop();
 this.grid.doClick(c);
 this.grid.editCell();
(e||event).cancelBubble=true;
}

 this.obj._onmousemove=this.obj.onmousemove;
 this.obj.onmousemove=this._autoMoveSelect;
 this._elmn=true;
}
}else{
 if(this._elmn){
 this.entBox.onclick = this.entBox._onclick;
 this.obj.onclick=function(){return true};
 this.obj.onmousemove=this.obj._onmousemove;
 this._elmn=false;
}
}
}


 
dhtmlXGridObject.prototype._unsetRowHover = function(e,c){
 if(c)that=this;else that=this.grid;

 if((that._lahRw)&&(that._lahRw!=c)){
 for(var i=0;i<that._lahRw.childNodes.length;i++)
 that._lahRw.childNodes[i].className=that._lahRw.childNodes[i].className.replace(that._hvrCss,"");
 that._lahRw=null;
}
}

 
dhtmlXGridObject.prototype._setRowHover = function(e){
 var c = this.grid.getFirstParentOfType(e?e.target:event.srcElement,'TD');
 if(c){
 this.grid._unsetRowHover(0,c);
 c=c.parentNode;
 for(var i=0;i<c.childNodes.length;i++)
 c.childNodes[i].className+=" "+this.grid._hvrCss;
 this.grid._lahRw=c;
}
 this._honmousemove(e);
}

 
dhtmlXGridObject.prototype._autoMoveSelect = function(e){
  if(!this.grid.editor)
{
 var c = this.grid.getFirstParentOfType(e?e.target:event.srcElement,'TD');
 if(c.parentNode.idd)
 this.grid.doClick(c,true,0);
}
 this._onmousemove(e);
}


 
dhtmlXGridObject.prototype.destructor=function(){
 var a;
 this.xmlLoader=this.xmlLoader.destructor();
 for(var i=0;i<this.rowsCol.length;i++)
 if(this.rowsCol[i])this.rowsCol[i].grid=null;
 for(i in this.rowsAr)
 if(this.rowsAr[i])this.rowsAr[i]=null;

 this.rowsCol=new dhtmlxArray();
 this.rowsAr=new Array();
 this.entBox.innerHTML="";
 this.entBox.onclick = function(){};
 this.entBox.onmousedown = function(){};
 this.entBox.onbeforeactivate = function(){};
 this.entBox.onbeforedeactivate = function(){};
 this.entBox.onbeforedeactivate = function(){};

 for(a in this){
 if((this[a])&&(this[a].m_obj))
 this[a].m_obj=null;
 this[a]=null;
}


 if(this==globalActiveDHTMLGridObject)
 globalActiveDHTMLGridObject=null;
  return null;
}





 
 dhtmlXGridObject.prototype.getSortingState=function(){
 var z=new Array();
 if(this.fldSorted){
 z[0]=this.fldSorted._cellIndex;
 z[1]=(this.sortImg.src.indexOf("sort_desc.gif")!=-1)?"DES":"ASC";
}
 return z;
};

 
 dhtmlXGridObject.prototype.enableAutoHeigth=function(mode,maxHeight){
 this._ahgr=convertStringToBoolean(mode);
 this._ahgrM=maxHeight||null;
 if(maxHeight=="auto")
{
 this._ahgrM=null;
 this._ahgrMA=true;
 this._activeResize();
}
};

 
 dhtmlXGridObject.prototype.enableStableSorting=function(mode){
 this._sst=convertStringToBoolean(mode);
 this.rowsCol.stablesort=function(cmp){
 for(var i=0;i<this.length-1;i++)
 for(var j=i;j<this.length;j++)
 if(cmp(this[i],this[j])){
 var temp=this[j];
 this[j]=this[i];
 this[i]=temp;
}
}
};

 
 dhtmlXGridObject.prototype.enableKeyboardSupport=function(mode){
 this._htkebl=!convertStringToBoolean(mode);
};


 
 dhtmlXGridObject.prototype.enableContextMenu=function(menu){
 this._ctmndx=menu;
};
 
 dhtmlXGridObject.prototype.setOnBeforeContextMenu=function(func){
 this.dhx_attachEvent("onBCM",func);
};

 
dhtmlXGridObject.prototype.setOnRightClick=function(func){
 this.dhx_attachEvent("onRCL",func);
};



 
 dhtmlXGridObject.prototype.setScrollbarWidthCorrection=function(width){
 this._scrFix=parseInt(width);
};

 
 dhtmlXGridObject.prototype.enableTooltips=function(list){
 this._enbTts=list.split(",");
 for(var i=0;i<this._enbTts.length;i++)
 this._enbTts[i]=convertStringToBoolean(this._enbTts[i]);
};


 
 dhtmlXGridObject.prototype.enableResizing=function(list){
 this._drsclmn=list.split(",");
 for(var i=0;i<this._drsclmn.length;i++)
 this._drsclmn[i]=convertStringToBoolean(this._drsclmn[i]);
};

 
 dhtmlXGridObject.prototype.setColumnMinWidth=function(width,ind){
 if(arguments.length==2){
 if(!this._drsclmW)this._drsclmW=new Array();
 this._drsclmW[ind]=width;
}
 else
 this._drsclmW=width.split(",");
};


  
 dhtmlXGridObject.prototype.enableCellIds=function(mode){
 this._enbCid=convertStringToBoolean(mode);
};
 


  
 dhtmlXGridObject.prototype.lockRow=function(rowId,mode){
 var z=this.getRowById(rowId);
 if(z){
 z._locked=convertStringToBoolean(mode);
 if((this.cell)&&(this.cell.parentNode.idd==rowId))
 this.editStop();
}
};
 
 
 dhtmlXGridObject.prototype._getRowArray=function(row){
 var text=new Array();
 for(var ii=0;ii<row.childNodes.length;ii++)
 text[ii]=this.cells3(row,ii).getValue();
 return text;
}


 
 dhtmlXGridObject.prototype.parseXML = function(xml,startIndex){
 this._xml_ready=true;
 var pid=null;
 var zpid=null;
 if(!xml)
 try{
 var xmlDoc = eval(this.entBox.id+"_xml").XMLDocument;
}catch(er){
 var xmlDoc = this.loadXML(this.xmlFileUrl)
}
 else{
 if(typeof(xml)=="object"){
 var xmlDoc = xml;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -