/*
Product Name: dhtmlxSuite
Version: 4.0.3
Edition: Professional
License: content of this file is covered by DHTMLX Commercial or Enterprise license. Usage without proper license is prohibited. To obtain it contact sales@dhtmlx.com
Copyright UAB Dinamenta http://www.dhtmlx.com
*/
/**
* @desc: add new column to the grid. Can be used after grid was initialized. At least one column should be in grid
* @param: ind - index of column
* @param: header - header content of column
* @param: type - type of column
* @param: width - width of column
* @param: sort - sort type of column
* @param: align - align of column
* @param: valign - vertical align of column
* @param: reserved - not used for now
* @param: columnColor - background color of column
* @type: public
* @edition: Professional
* @topic: 3
*/
dhtmlXGridObject.prototype.insertColumn=function(ind,header,type,width,sort,align,valign,reserved,columnColor){
ind=parseInt(ind);
if (ind>this._cCount) ind=this._cCount;
if (!this._cMod) this._cMod=this._cCount;
this._processAllArrays(this._cCount,ind-1,[(header||" "),(width||100),(type||"ed"),(align||"left"),(valign||""),(sort||"na"),(columnColor||""),"",this._cMod,(width||100)]);
this._processAllRows("_addColInRow",ind);
if (typeof(header)=="object")
for (var i=1; i < this.hdr.rows.length; i++) {
if (header[i-1]=="#rspan"){
var pind=i-1;
var found=false;
var pz=null;
while(!found){
var pz=this.hdr.rows[pind];
for (var j=0; j=this._cCount) return;
this._processAllArrays(ind,this._cCount-1,[null,null,null,null,null,null,null,null,null,null,null]);
this._processAllRows("_deleteColInRow",ind);
this._cCount--;
this._master_row=null;
this.setSizes();
}
/**
* @desc: call method for all rows in all collections
* @type: private
* @topic: 0
*/
dhtmlXGridObject.prototype._processAllRows = function(method,oldInd,newInd){
this[method](this.obj.rows[0],oldInd,newInd,0);
var z=this.hdr.rows.length;
for (var i=0; i(newInd+1); j--)
t[j]=t[j-1];
t[newInd+1]=val;
}
if (vals)
t[newInd+(mode?0:1)]=vals[i];
}
}
}
/**
* @desc: moves column of specified index to new position
* @param: oldInd - current index of column
* @param: newInd - new index of column
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.moveColumn = function(oldInd,newInd){
newInd--;
oldInd=parseInt(oldInd); newInd=parseInt(newInd);
if (newInd=ind; i--)
row._childIndexes[i]=i?(row._childIndexes[i-1]+1):0;
row._childIndexes[ind]--;
}
else
for (var i = row._childIndexes.length; i >= ind; i--)
row._childIndexes[i]=i?(row._childIndexes[i-1]+1):0;
var cind=row._childIndexes[ind];
}
var c=row.childNodes[cind];
var z=document.createElement((mod)?"TD":"TH");
if (mod) { z._attrs={}; } //necessary for code compressor
else z.style.width=(parseInt(this.cellWidthPX[ind])||"100")+"px";
if (c)
row.insertBefore(z,c);
else
row.appendChild(z);
if (this.dragAndDropOff && row.idd) this.dragger.addDraggableItem(row.childNodes[cind],this);
for (var i=cind+1; i1 && c.parentNode.idd){
var t=c.colSpan-1;
var v=this.cells4(c).getValue();
this.setColspan(c.parentNode.idd,c._cellIndex,1)
if (t>1){
var cind=c._cellIndex*1;
this.setColspan(c.parentNode.idd,cind+1,t)
this.cells(c.parentNode.idd,c._cellIndex*1+1).setValue(v)
row._childIndexes.splice(cind,1)
for (var i=cind; i < row._childIndexes.length; i++)
row._childIndexes[i]-=1;
}
} else if (row._childIndexes){
row._childIndexes.splice(aind,1);
for (var i=aind; i0.5){
he.className+=" columnTargetR";
grid._colInMove._bIndex=el._cellIndexS;
}
else {
he.className+=" columnTargetL";
grid._colInMove._bIndex=el._cellIndexS-1;
}
if (he.offsetLeft<(grid.objBox.scrollLeft+20))
grid.objBox.scrollLeft=Math.max(0,he.offsetLeft-20);
if ((he.offsetLeft+he.offsetWidth-grid.objBox.scrollLeft)>(grid.objBox.offsetWidth-20))
grid.objBox.scrollLeft=Math.min(grid.objBox.scrollLeft+he.offsetWidth+20,grid.objBox.scrollWidth-grid.objBox.offsetWidth);
grid._colInMove._oldHe=he;
}
//prevent selection, or other similar reactions while column draged
e.cancelBubble = true;
return false;
}
return true;
};
dhtmlXGridObject.prototype._stopColumnMove = function(e){
e=e||event;
var grid=window.globalActiveDHTMLGridObject;
if ((grid)&&(grid._colInMove)){
if (typeof(grid._colInMove)=="object"){
grid._colInMove.parentNode.removeChild(grid._colInMove);
if (grid._colInMove._bIndex!=null)
grid.moveColumn(grid._colInMove._aIndex,grid._colInMove._bIndex+1);
if (grid._colInMove._oldHe)
grid._colInMove._oldHe.className=grid._colInMove._oldHe.className.replace(/columnTarget(L|R)/g,"");
grid._colInMove._oldHe=null;
grid._colInMove.grid=null;
grid.resized = true;
}
grid._colInMove=0;
}
return true;
};
//(c)dhtmlx ltd. www.dhtmlx.com