};if (this._ivizcol)this.setColHidden();this.attachHeader();this.attachHeader(0,0,"_aFoot");this.setSizes();if(fl)this.parseXML() this.obj.scrollTop = 0 if (this.dragAndDropOff)this.dragger.addDragLanding(this.entBox,this);if (this._initDrF)this._initD();if (this._init_point)this._init_point()};this.setSizes = function(fl){if ((!this.hdr.rows[0])) return;if (!this.entBox.offsetWidth){if (this._sizeTime)window.clearTimeout(this._sizeTime);this._sizeTime=window.setTimeout(function(){self.setSizes()},250);return};if (((_isFF)&&(this.entBox.style.height=="100%"))||(this._fixLater)){this.entBox.style.height=this.entBox.parentNode.clientHeight;this._fixLater=true};if(fl && this.gridWidth==this.entBox.offsetWidth && this.gridHeight==this.entBox.offsetHeight){return false }else if(fl){this.gridWidth = this.entBox.offsetWidth this.gridHeight = this.entBox.offsetHeight };if ((!this.hdrBox.offsetHeight)&&(this.hdrBox.offsetHeight>0)) this.entCnt.rows[0].cells[0].height = this.hdrBox.offsetHeight+"px";var gridWidth = parseInt(this.entBox.offsetWidth)-(this._gcCorr||0);var gridHeight = parseInt(this.entBox.offsetHeight)-((!_isIE)?(this._sizeFix||0):0);var _isVSroll=(this.objBox.scrollHeight>this.objBox.offsetHeight);if (((!this._ahgr)&&(_isVSroll))||((this._ahgrM)&&(this._ahgrMms?min:ms):ms)-this._wcorr;summ+=ms}};var summ = 0;for(var i=0;ithis._awdth[1]?this._awdth[1]:(summthis._ahgrM))) gridHeight=this._ahgrM*1+(this._ahgrF?0:(zheight+scrfix));else gridHeight=z2+zheight+scrfix;this.entBox.style.height=gridHeight+"px"};if (this.ftr)zheight-=this.ftr.offsetHeight;var aRow=this.entCnt.rows[1].cells[0].childNodes[0];if(!this.noHeader)aRow.style.top = (zheight-this.hdrBox.offsetHeight+((_isIE && !window.XMLHttpRequest)?(-wcor):0) )+"px";if (this._topMb){this._topMb.style.top=(zheight||0)+"px";this._topMb.style.width=(gridWidth+20)+"px"};if (this._botMb){this._botMb.style.top=(gridHeight-3)+"px";this._botMb.style.width=(gridWidth+20)+"px"};aRow.style.height = (((gridHeight - zheight-1)<0 && _isIE)?20:(gridHeight - zheight-1))-(this.ftr?this.ftr.offsetHeight:0)+"px";if (this.ftr && this.entBox.offsetHeight>this.ftr.offsetHeight)this.entCnt.style.height=this.entBox.offsetHeight-this.ftr.offsetHeight+"px";if (this._dload)this._dloadSize=Math.floor(parseInt(this.entBox.offsetHeight)/20)+(_isKHTML?4:2)};this.chngCellWidth = function(){if ((_isOpera)&&(this.ftr)) this.ftr.width=this.objBox.scrollWidth+"px";var l=this._cCount;for(var i=0;i1){var a_sizes=new Array();for (var i=0;i((this._drsclmW && !this._notresize)?(this._drsclmW[ind]||10):10)){this.obj.firstChild.firstChild.childNodes[ind].style.width = fcolW+"px";this.hdr.rows[0].childNodes[ind].style.width = fcolW+"px";if (this.ftr)this.ftr.rows[0].childNodes[ind].style.width = fcolW+"px";if(this.cellWidthType=='px'){this.cellWidthPX[ind]=fcolW}else{var gridWidth = parseInt(this.entBox.offsetWidth);if (this.objBox.scrollHeight>this.objBox.offsetHeight)gridWidth-=(this._scrFix||(_isFF?19:16));var pcWidth = Math.round(fcolW/gridWidth*100) this.cellWidthPC[ind]=pcWidth}}};this.setSortImgState=function(state,ind,order,row){order=(order||"asc").toLowerCase();if (!convertStringToBoolean(state)){this.sortImg.style.display = "none";this.fldSorted=null;return};if (order=="asc")this.sortImg.src = this.imgURL+"sort_asc.gif";else this.sortImg.src = this.imgURL+"sort_desc.gif";this.sortImg.style.display="";this.fldSorted=this.hdr.rows[0].cells[ind];this.r_fldSorted=this.hdr.rows[row||1].cells[ind];this.setSortImgPos(ind)};this.setSortImgPos = function(ind,mode,hRowInd,el){if (!el){if(!ind)var el = this.r_fldSorted;else var el = this.hdr.rows[hRowInd||0].cells[ind]};if(el!=null){var pos = this.getPosition(el,this.hdrBox) var wdth = el.offsetWidth;this.sortImg.style.left = Number(pos[0]+wdth-13)+"px";this.sortImg.defLeft = parseInt(this.sortImg.style.left) this.sortImg.style.top = Number(pos[1]+5)+"px";if ((!this.useImagesInHeader)&&(!mode)) this.sortImg.style.display = "inline";this.sortImg.style.left = this.sortImg.defLeft+"px"}};this.setActive = function(fl){if(arguments.length==0)var fl = true;if(fl==true){if (globalActiveDHTMLGridObject && ( globalActiveDHTMLGridObject != this )) globalActiveDHTMLGridObject.editStop();globalActiveDHTMLGridObject = this;this.isActive = true}else{this.isActive = false}};this._doClick = function(ev){var selMethod = 0;var el = this.getFirstParentOfType(_isIE?ev.srcElement:ev.target,"TD");var fl = true;if(this.selMultiRows!=false){if((ev.shiftKey || ev.metaKey)&& this.row!=null){selMethod = 1};if(ev.ctrlKey){selMethod = 2}};this.doClick(el,fl,selMethod) };this._doContClick=function(ev){var el = this.getFirstParentOfType(_isIE?ev.srcElement:ev.target,"TD");if ((!el)||(typeof(el.parentNode.idd)=="undefined")) return true;if (ev.button==2 || (_isKHTML && ev.ctrlKey)){if (!this.callEvent("onRightClick",[el.parentNode.idd,el._cellIndex,ev])) {var z=function(e){document.body.oncontextmenu=Function("return true;");(e||event).cancelBubble=true;return false};if (_isIE)ev.srcElement.oncontextmenu=z;else if (!_isMacOS)document.body.oncontextmenu=z;return false};if (this._ctmndx){if (!(this.callEvent("onBeforeContextMenu",[el.parentNode.idd,el._cellIndex,this]))) return true;el.contextMenuId=el.parentNode.idd+"_"+el._cellIndex;el.contextMenu=this._ctmndx;el.a=this._ctmndx._contextStart;if (_isIE)ev.srcElement.oncontextmenu = function(){event.cancelBubble=true;return false};el.a(el,ev);el.a=null}}else if(this._ctmndx)this._ctmndx._contextEnd();return true};this.doClick = function(el,fl,selMethod,show){var psid=this.row?this.row.idd:0;this.setActive(true);if(!selMethod)selMethod = 0;if(this.cell!=null)this.cell.className = this.cell.className.replace(/cellselected/g,"");if(el.tagName=="TD" && (this.rowsCol._dhx_find(this.rowsAr[el.parentNode.idd])!=-1 || this.rowsBuffer[0]._dhx_find(el.parentNode.idd)!=-1)){if (this.checkEvent("onSelectStateChanged")) var initial=this.getSelectedId();var prow=this.row;if(selMethod==0){this.clearSelection()}else if(selMethod==1){var elRowIndex = this.rowsCol._dhx_find(el.parentNode) var lcRowIndex = this.rowsCol._dhx_find(this.lastClicked) if(elRowIndex>lcRowIndex){var strt = lcRowIndex;var end = elRowIndex}else{var strt = elRowIndex;var end = lcRowIndex};for(var i=0;i=strt && i<=end)){if (this.rowsCol[i] && (!this.rowsCol[i]._sRow)){if (this.rowsCol[i].className.indexOf("rowselected")==-1 && this.callEvent("onBeforeSelect",[this.rowsCol[i].idd,psid])){this.rowsCol[i].className+=" rowselected";this.selectedRows[this.selectedRows.length] = this.rowsCol[i] }}else{this.clearSelection();return this.doClick(el,fl,0,show)}}}else if(selMethod==2){if(el.parentNode.className.indexOf("rowselected")!= -1){el.parentNode.className=el.parentNode.className.replace(/rowselected/g,"");this.selectedRows._dhx_removeAt(this.selectedRows._dhx_find(el.parentNode)) var skipRowSelection = true}};this.editStop() this.cell = el;if ((prow == el.parentNode)&&(this._chRRS)) fl=false;if (typeof(el.parentNode.idd)=="undefined") return true;this.row = el.parentNode;if((!skipRowSelection)&&(!this.row._sRow)){if (this.callEvent("onBeforeSelect",[this.row.idd,psid])){this.row.className+= " rowselected" if(this.selectedRows._dhx_find(this.row)==-1) this.selectedRows[this.selectedRows.length] = this.row}else this.row=prow};if(this.selBasedOn=="cell"){if (this.cell.parentNode.className.indexOf("rowselected")!=-1) this.cell.className = this.cell.className.replace(/cellselected/g,"")+" cellselected"};if(selMethod!=1)if (!this.row)return;this.lastClicked = el.parentNode;var rid = this.row.idd;var cid = this.cell.cellIndex;if (fl && typeof(rid)!="undefined") self.onRowSelectTime=setTimeout(function(){self.callEvent("onRowSelect",[rid,cid])},100) if (this.checkEvent("onSelectStateChanged")) {var afinal=this.getSelectedId();if (initial!=afinal)this.callEvent("onSelectStateChanged",[afinal])}};this.isActive = true;if (show!==false)this.moveToVisible(this.cell) };this.selectAll = function(){this.clearSelection();this.selectedRows=dhtmlxArray([].concat(this.rowsCol));if (this.selectedRows.length){this.row=this.selectedRows[0];this.cell=this.row.cells[0]};for (var i=0;i(this.objBox.offsetWidth+this.objBox.scrollLeft)){var scrollLeft = distance - this.objBox.offsetWidth}else if(cell_obj.offsetLeft(this.objBox.offsetHeight+this.objBox.scrollTop)){var scrollTop = distance - this.objBox.offsetHeight}else if(cell_obj.offsetTop(new Date).valueOf()) return;this._Opera_stop=null};if(this.editor && this.editor!=null){this.editor.cell.className=this.editor.cell.className.replace("editable","");if (mode){var t=this.editor.val;this.editor.detach();this.editor.setValue(t);this.editor=null;return};if (this.editor.detach()) this.cell.wasChanged = true;var g=this.editor;this.editor=null;var z=this.callEvent("onEditCell",[2,this.row.idd,this.cell._cellIndex,g.getValue(),g.val]);if ((typeof(z)=="string")||(typeof(z)=="number")) g[g.setImage?"setLabel":"setValue"](z);else if (!z)g[g.setImage?"setLabel":"setValue"](g.val)}};this._nextRowCell=function(row,dir,pos){row=this._nextRow(this.rowsCol._dhx_find(row),dir);if (!row)return null;return row.childNodes[row._childIndexes?row._childIndexes[pos]:pos]};this._getNextCell=function(acell,dir,i){acell=acell||this.cell;var arow=this.cell.parentNode;if (this._tabOrder){i=this._tabOrder[acell._cellIndex];if (typeof i != "undefined")if (i < 0)acell=this._nextRowCell(arow,dir,Math.abs(i)-1);else acell=arow.childNodes[i]}else {var i=acell._cellIndex+dir;if (i >= 0 && i < this._cCount ){if (arow._childIndexes)i=arow._childIndexes[acell._cellIndex]+dir;acell=arow.childNodes[i]}else acell=this._nextRowCell(arow,dir,(dir==1?0:(this._cCount-1)))};if (!acell)return null;if (acell.style.display!="none")return acell;return this._getNextCell(acell,dir)};this._nextRow=function(ind,dir){var r=this.rowsCol[ind+dir];if (r && r.style.display=="none")return this._nextRow(ind+dir,dir);return r};this.scrollPage = function(dir){var new_ind=Math.floor((this.getRowIndex(this.row.idd)||0)+(dir)*this.objBox.offsetHeight/(this._srdh||20));if (new_ind<0)new_ind=0;if (this._dload && (!this.rowsCol[new_ind])){this._askRealRows(new_ind,function(){try{self.selectCell(new_ind,(this.cell?this.cell._cellIndex:0),true)}catch(e){}})}else{if (new_ind>=this.rowsCol.length)new_ind=this.rowsCol.length-1;this.selectCell(new_ind,this.cell._cellIndex,true)}};this.doKey = function(ev){if (!ev)return true;if ((ev.target||ev.srcElement).value!==window.undefined){var zx= (ev.target||ev.srcElement);if ((!zx.parentNode)||(zx.parentNode.className.indexOf("editable")==-1)) return true};if ((globalActiveDHTMLGridObject)&&(this!=globalActiveDHTMLGridObject)) return globalActiveDHTMLGridObject.doKey(ev);if(this.isActive==false){return true};if (this._htkebl)return true;if (!this.callEvent("onKeyPress",[ev.keyCode,ev.ctrlKey,ev.shiftKey,ev])) return false;var code="k"+ev.keyCode+"_"+(ev.ctrlKey?1:0)+"_"+(ev.shiftKey?1:0);if (this.cell){if (this._key_events[code]){if (false===this._key_events[code].call(this)) return true;_isIE?ev.returnValue=false:ev.preventDefault();ev.cancelBubble=true;return false};if (this._key_events["k_other"])this._key_events.k_other.call(this,ev)};return true};this.getRow = function(cell){if(!cell)cell = window.event.srcElement;if(cell.tagName!='TD')cell = cell.parentElement;r = cell.parentElement;if(this.cellType[cell._cellIndex]=='lk')eval(this.onLink+"('"+this.getRowId(r.rowIndex)+"',"+cell._cellIndex+")");this.selectCell(r,cell._cellIndex,true) };this.selectRow = function(r,fl,preserve,show){if(typeof(r)!='object') r = this.rowsCol[r] this.selectCell(r,0,fl,preserve,false,show) };this.sortRows = function(col,type,order){order=(order||"asc").toLowerCase();type=(type||this.fldSort[col]);while(this.addRowsFromBuffer(true));if(this.cellType._dhx_find("tree")!=-1){return this.sortTreeRows(col,type,order) };var self=this;var arrTS=new Array();var atype = this.cellType[col];var amet="getValue";if (atype=="link")amet="getContent";if (atype=="dhxCalendar" || atype=="dhxCalendarA")amet="getDate";for (var i=0;i4)type=window[type];if(type=='cus'){s[sort](function(a,b){return self._customSorts[col](arrTS[a.idd],arrTS[b.idd],order,a.idd,b.idd)})}else if(typeof(type)=='function'){s[sort](function(a,b){return type(arrTS[a.idd],arrTS[b.idd],order,a.idd,b.idd)})}else if(type=='str'){s[sort](function(a,b){if(order=="asc")return arrTS[a.idd]>arrTS[b.idd]?1:-1 else return arrTS[a.idd]