",
this.cell.chstate);
}
//}
//ra_excell:04062008{
/**
* @desc: radio editor
* @returns: dhtmlxGrid cell editor object
* @type: public
*/
function eXcell_ra(cell){
this.base=eXcell_ch;
this.base(cell)
this.grid=cell.parentNode.grid;
this.disabledF=function(fl){
if ((fl == true)||(fl == 1))
this.cell.innerHTML=this.cell.innerHTML.replace("radio_chk0.", "radio_chk0_dis.").replace("radio_chk1.",
"radio_chk1_dis.");
else
this.cell.innerHTML=this.cell.innerHTML.replace("radio_chk0_dis.", "radio_chk0.").replace("radio_chk1_dis.",
"radio_chk1.");
}
this.changeState=function(mode){
if (mode===false && this.getValue()==1) return;
if ((!this.grid.isEditable)||(this.cell.parentNode._locked))
return;
if (this.grid.callEvent("onEditCell", [
0,
this.cell.parentNode.idd,
this.cell._cellIndex
]) != false){
this.val=this.getValue()
if (this.val == "1")
this.setValue("0")
else
this.setValue("1")
this.cell.wasChanged=true;
//nb:
this.grid.callEvent("onEditCell", [
1,
this.cell.parentNode.idd,
this.cell._cellIndex
]);
this.grid.callEvent("onCheckbox", [
this.cell.parentNode.idd,
this.cell._cellIndex,
(this.val != '1')
]);
this.grid.callEvent("onCheck", [
this.cell.parentNode.idd,
this.cell._cellIndex,
(this.val != '1')
]);
} else { //preserve editing (not tested thoroughly for this editor)
this.editor=null;
}
}
this.edit=null;
}
eXcell_ra.prototype=new eXcell_ch;
eXcell_ra.prototype.setValue=function(val){
this.cell.style.verticalAlign="middle"; //nb:to center checkbox in line
if (val){
val=val.toString()._dhx_trim();
if ((val == "false")||(val == "0"))
val="";
}
if (val){
if (!this.grid._RaSeCol)
this.grid._RaSeCol=[];
if (this.grid._RaSeCol[this.cell._cellIndex]){
var z = this.grid.cells4(this.grid._RaSeCol[this.cell._cellIndex]);
z.setValue("0")
if (this.grid.rowsAr[z.cell.parentNode.idd])
this.grid.callEvent("onEditCell", [
1,
z.cell.parentNode.idd,
z.cell._cellIndex
]);
}
this.grid._RaSeCol[this.cell._cellIndex]=this.cell;
val="1";
this.cell.chstate="1";
} else {
val="0";
this.cell.chstate="0"
}
this.setCValue("
",
this.cell.chstate);
}
//}
//txt_excell:04062008{
/**
* @desc: multilene popup editor
* @returns: dhtmlxGrid cell editor object
* @type: public
*/
function eXcell_txt(cell){
if (cell){
this.cell=cell;
this.grid=this.cell.parentNode.grid;
}
this.edit=function(){
this.val=this.getValue()
this.obj=document.createElement("TEXTAREA");
this.obj.className="dhx_textarea";
this.obj.onclick=function(e){
(e||event).cancelBubble=true
}
var arPos = this.grid.getPosition(this.cell); //,this.grid.objBox
this.obj.value=this.val;
this.obj.style.display="";
this.obj.style.textAlign=this.cell.style.textAlign;
if (_isFF){
var z_ff = document.createElement("DIV");
z_ff.appendChild(this.obj);
z_ff.style.overflow="auto";
z_ff.className="dhx_textarea";
this.obj.style.margin="0px 0px 0px 0px";
this.obj.style.border="0px";
this.obj=z_ff;
}
document.body.appendChild(this.obj); //nb:
if(_isOpera) this.obj.onkeypress=function(ev){ if (ev.keyCode == 9) return false; }
this.obj.onkeydown=function(e){
var ev = (e||event);
if (ev.keyCode == 9){
globalActiveDHTMLGridObject.entBox.focus();
globalActiveDHTMLGridObject.doKey({
keyCode: ev.keyCode,
shiftKey: ev.shiftKey,
srcElement: "0"
});
return false;
}
}
this.obj.style.left=arPos[0]+"px";
this.obj.style.top=arPos[1]+this.cell.offsetHeight+"px";
if (this.cell.offsetWidth < 200)
var pw = 200;
else
var pw = this.cell.offsetWidth;
this.obj.style.width=pw+(_isFF ? 18 : 16)+"px"
if (_isFF){
this.obj.firstChild.style.width=parseInt(this.obj.style.width)+"px";
this.obj.firstChild.style.height=this.obj.offsetHeight-3+"px";
}
if (_isIE) { this.obj.select(); this.obj.value=this.obj.value; }//dzen of IE
if (_isFF)
this.obj.firstChild.focus();
else {
this.obj.focus()
}
}
this.detach=function(){
var a_val = "";
if (_isFF)
a_val=this.obj.firstChild.value;
else
a_val=this.obj.value;
if (a_val == ""){
this.cell._clearCell=true;
}
else
this.cell._clearCell=false;
this.setValue(a_val);
document.body.removeChild(this.obj);
this.obj=null;
return this.val != this.getValue();
}
this.getValue=function(){
if (this.obj){
if (_isFF)
return this.obj.firstChild.value;
else
return this.obj.value;
}
if (this.cell._clearCell)
return "";
if ((!this.grid.multiLine))
return this.cell._brval||this.cell.innerHTML;
else
return this.cell.innerHTML.replace(/
";
this.entBox.appendChild(this._topMb);
this._botMb=document.createElement("DIV");
this._botMb.className="bottomMumba";
this._botMb.innerHTML="
";
this.entBox.appendChild(this._botMb);
if (this.entBox.style.position != "absolute")
this.entBox.style.position="relative";
this.skin_h_correction=20;
break;
case "dhx_skyblue":
case "dhx_web":
case "glassy_blue":
case "dhx_black":
case "dhx_blue":
case "modern":
case "light":
this._srdh=20;
this.forceDivInHeader=true;
break;
case "xp":
this.forceDivInHeader=true;
if ((_isIE)&&(document.compatMode != "BackCompat"))
this._srdh=26;
else this._srdh=22;
break;
case "mt":
if ((_isIE)&&(document.compatMode != "BackCompat"))
this._srdh=26;
else this._srdh=22;
break;
case "gray":
if ((_isIE)&&(document.compatMode != "BackCompat"))
this._srdh=22;
break;
case "sbdark":
break;
}
if (_isIE&&this.hdr){
var d = this.hdr.parentNode;
d.removeChild(this.hdr);
d.appendChild(this.hdr);
}
this.setSizes();
}
if (_isIE)
this.preventIECaching(true);
if (window.dhtmlDragAndDropObject)
this.dragger=new dhtmlDragAndDropObject();
/*METHODS. SERVICE*/
/**
* @desc: on scroll grid inner actions
* @type: private
* @topic: 7
*/
this._doOnScroll=function(e, mode){
this.callEvent("onScroll", [
this.objBox.scrollLeft,
this.objBox.scrollTop
]);
this.doOnScroll(e, mode);
}
/**
* @desc: on scroll grid more inner action
* @type: private
* @topic: 7
*/
this.doOnScroll=function(e, mode){
this.hdrBox.scrollLeft=this.objBox.scrollLeft;
if (this.ftr)
this.ftr.parentNode.scrollLeft=this.objBox.scrollLeft;
if (mode)
return;
if (this._srnd){
if (this._dLoadTimer)
window.clearTimeout(this._dLoadTimer);
this._dLoadTimer=window.setTimeout(function(){
if (self._update_srnd_view)
self._update_srnd_view();
}, 100);
}
}
/**
* @desc: attach grid to some object in DOM
* @param: obj - object to attach to
* @type: public
* @topic: 0,7
*/
this.attachToObject=function(obj){
obj.appendChild(this.globalBox?this.globalBox:this.entBox);
//this.objBox.style.height=this.entBox.style.height;
this.setSizes();
}
/**
* @desc: initialize grid
* @param: fl - if to parse on page xml data island
* @type: public
* @topic: 0,7
*/
this.init=function(fl){
if ((this.isTreeGrid())&&(!this._h2)){
this._h2=new dhtmlxHierarchy();
if ((this._fake)&&(!this._realfake))
this._fake._h2=this._h2;
this._tgc={
imgURL: null
};
}
if (!this._hstyles)
return;
this.editStop()
/*TEMPORARY STATES*/
this.lastClicked=null; //row clicked without shift key. used in multiselect only
this.resized=null; //hdr cell that is resized now
this.fldSorted=this.r_fldSorted=null; //hdr cell last sorted
//empty grid if it already was initialized
this.cellWidthPX=[];
this.cellWidthPC=[];
if (this.hdr.rows.length > 0){
this.clearAll(true);
}
var hdrRow = this.hdr.insertRow(0);
for (var i = 0; i < this.hdrLabels.length; i++){
hdrRow.appendChild(document.createElement("TH"));
hdrRow.childNodes[i]._cellIndex=i;
hdrRow.childNodes[i].style.height="0px";
}
if (_isIE && _isIE<8)
hdrRow.style.position="absolute";
else
hdrRow.style.height='auto';
var hdrRow = this.hdr.insertRow(_isKHTML ? 2 : 1);
hdrRow._childIndexes=new Array();
var col_ex = 0;
for (var i = 0; i < this.hdrLabels.length; i++){
hdrRow._childIndexes[i]=i-col_ex;
if ((this.hdrLabels[i] == this.splitSign)&&(i != 0)){
if (_isKHTML)
hdrRow.insertCell(i-col_ex);
hdrRow.cells[i-col_ex-1].colSpan=(hdrRow.cells[i-col_ex-1].colSpan||1)+1;
hdrRow.childNodes[i-col_ex-1]._cellIndex++;
col_ex++;
hdrRow._childIndexes[i]=i-col_ex;
continue;
}
hdrRow.insertCell(i-col_ex);
hdrRow.childNodes[i-col_ex]._cellIndex=i;
hdrRow.childNodes[i-col_ex]._cellIndexS=i;
this.setColumnLabel(i, this.hdrLabels[i]);
}
if (col_ex == 0)
hdrRow._childIndexes=null;
this._cCount=this.hdrLabels.length;
if (_isIE)
window.setTimeout(function(){
if (self.setSizes)
self.setSizes();
}, 1);
//create virtual top row
if (!this.obj.firstChild)
this.obj.appendChild(document.createElement("TBODY"));
var tar = this.obj.firstChild;
if (!tar.firstChild){
tar.appendChild(document.createElement("TR"));
tar=tar.firstChild;
if (_isIE && _isIE<8)
tar.style.position="absolute";
else
tar.style.height='auto';
for (var i = 0; i < this.hdrLabels.length; i++){
tar.appendChild(document.createElement("TH"));
tar.childNodes[i].style.height="0px";
}
}
this._c_order=null;
if (this.multiLine != true)
this.obj.className+=" row20px";
//
//this.combos = new Array(this.hdrLabels.length);
//set sort image to initial state
this.sortImg.style.position="absolute";
this.sortImg.style.display="none";
this.sortImg.src=this.imgURL+"sort_desc.gif";
this.sortImg.defLeft=0;
if (this.noHeader){
this.hdrBox.style.display='none';
}
else {
this.noHeader=false
}
//__pro_feature:21092006{
//column_hidden:21092006{
if (this._ivizcol)
this.setColHidden();
//}
//}
//header_footer:06042008{
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.setColumnSizes=function(gridWidth){
var summ = 0;
var fcols = []; //auto-size columns
var fix = 0;
for (var i = 0; i < this._cCount; i++){
if ((this.initCellWidth[i] == "*") && !this._hrrar[i]){
this._awdth=false; //disable auto-width
fcols.push(i);
continue;
}
if (this.cellWidthType == '%'){
if (typeof this.cellWidthPC[i]=="undefined")
this.cellWidthPC[i]=this.initCellWidth[i];
var cwidth = (gridWidth*this.cellWidthPC[i]/100)||0;
if (fix>0.5){
cwidth++;
fix--;
}
var rwidth = this.cellWidthPX[i]=Math.floor(cwidth);
var fix =fix + cwidth - rwidth;
} else{
if (typeof this.cellWidthPX[i]=="undefined")
this.cellWidthPX[i]=this.initCellWidth[i];
}
if (!this._hrrar[i])
summ+=this.cellWidthPX[i]*1;
}
//auto-size columns
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) : 0),ms)
this.cellWidthPX[fcols[i]]=next;
summ+=next;
}
if(gridWidth > summ){
var last=fcols[fcols.length-1];
this.cellWidthPX[last]=this.cellWidthPX[last] + (gridWidth-summ);
summ = gridWidth;
}
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;
}
/**shz)_
* @desc: sets sizes of grid elements
* @type: private
* @topic: 0,7
*/
this.setSizes=function(){
//drop processing if grid still not initialized
if ((!this.hdr.rows[0])) return;
var quirks=this.quirks = (_isIE && document.compatMode=="BackCompat");
var outerBorder=(this.entBox.offsetWidth-this.entBox.clientWidth)/2;
if (this.globalBox){
var splitOuterBorder=(this.globalBox.offsetWidth-this.globalBox.clientWidth)/2;
if (this._delta_x && !this._realfake){
var ow = this.globalBox.clientWidth;
this.globalBox.style.width=this._delta_x;
this.entBox.style.width=Math.max(0,(this.globalBox.clientWidth+(quirks?splitOuterBorder*2:0))-this._fake.entBox.clientWidth)+"px";
if (ow != this.globalBox.clientWidth){
this._fake._correctSplit(this._fake.entBox.clientWidth);
}
}
if (this._delta_y && !this._realfake){
this.globalBox.style.height = this._delta_y;
this.entBox.style.overflow = this._fake.entBox.style.overflow="hidden";
this.entBox.style.height = this._fake.entBox.style.height=this.globalBox.clientHeight+(quirks?splitOuterBorder*2:0)+"px";
}
} else {
if (this._delta_x){
/*when placed directly in TD tag, container can't use native percent based sizes,
because table auto-adjust to show all content - too clever*/
if (this.entBox.parentNode && this.entBox.parentNode.tagName=="TD"){
this.entBox.style.width="1px";
this.entBox.style.width=parseInt(this._delta_x)*this.entBox.parentNode.clientWidth/100-outerBorder*2+"px";
}else
this.entBox.style.width=this._delta_x;
}
if (this._delta_y)
this.entBox.style.height=this._delta_y;
}
//if we have container without sizes, wait untill sizes defined
window.clearTimeout(this._sizeTime);
if (!this.entBox.offsetWidth && (!this.globalBox || !this.globalBox.offsetWidth)){
this._sizeTime=window.setTimeout(function(){
if (self.setSizes)
self.setSizes();
}, 250);
return;
}
var border_x = ((!this._wthB) && ((this.entBox.cmp||this._delta_x) && (this.skin_name||"").indexOf("dhx")==0 && !quirks)?2:0);
var border_y = ((!this._wthB) && ((this.entBox.cmp||this._delta_y) && (this.skin_name||"").indexOf("dhx")==0 && !quirks)?2:0);
var isVScroll = this.parentGrid?false:(this.objBox.scrollHeight > this.objBox.offsetHeight);
var scrfix = _isFF?18:18;
var gridWidth=this.entBox.clientWidth-(this.skin_h_correction||0)*(quirks?0:1)-border_x;
var gridWidthActive=this.entBox.clientWidth-(this.skin_h_correction||0)-border_x;
var gridHeight=this.entBox.clientHeight-border_y;
var summ=this.setColumnSizes(gridWidthActive-(isVScroll?scrfix:0)-(this._correction_x||0));
var isHScroll = this.parentGrid?false:((this.objBox.scrollWidth > this.objBox.offsetWidth)||(this.objBox.style.overflowX=="scroll"));
var headerHeight = this.hdr.clientHeight;
var footerHeight = this.ftr?this.ftr.clientHeight:0;
var newWidth=gridWidth;
var newHeight=gridHeight-headerHeight-footerHeight;
//if we have auto-width without limitations - ignore h-scroll
if (this._awdth && this._awdth[0] && this._awdth[1]==99999) isHScroll=0;
//auto-height
if (this._ahgr){
if (this._ahgrMA)
newHeight=this.entBox.parentNode.clientHeight-headerHeight-footerHeight;
else
newHeight=this.obj.offsetHeight+(isHScroll?scrfix:0)+(this._correction_y||0);
if (this._ahgrM){
if (this._ahgrF)
newHeight=Math.min(this._ahgrM,newHeight+headerHeight+footerHeight)-headerHeight-footerHeight;
else
newHeight=Math.min(this._ahgrM,newHeight);
}
if (isVScroll && newHeight>=this.obj.scrollHeight+(isHScroll?scrfix:0)){
isVScroll=false;//scroll will be compensated;
this.setColumnSizes(gridWidthActive-(this._correction_x||0)); //correct auto-size columns
}
}
//auto-width
if ((this._awdth)&&(this._awdth[0])){
//convert percents to PX, because auto-width with procents has no sense
if (this.cellWidthType == '%') this.cellWidthType="px";
if (this._fake) summ+=this._fake.entBox.clientWidth; //include fake grid in math
var newWidth=Math.min(Math.max(summ+(isVScroll?scrfix:0),this._awdth[2]),this._awdth[1])+(this._correction_x||0);
if (this._fake) newWidth-=this._fake.entBox.clientWidth;
}
newHeight=Math.max(0,newHeight);//validate value for IE
//FF3.1, bug in table rendering engine
this._ff_size_delta=(this._ff_size_delta==0.1)?0.2:0.1;
if (!_isFF) this._ff_size_delta=0;
this.entBox.style.width=Math.max(0,newWidth+(quirks?2:0)*outerBorder+this._ff_size_delta)+"px";
this.entBox.style.height=newHeight+(quirks?2:0)*outerBorder+headerHeight+footerHeight+"px";
this.objBox.style.height=newHeight+((quirks&&!isVScroll)?2:0)*outerBorder+"px";//):this.entBox.style.height);
this.hdrBox.style.height=headerHeight+"px";
if (newHeight != gridHeight)
this.doOnScroll(0, !this._srnd);
var ext=this["setSizes_"+this.skin_name];
if (ext) ext.call(this);
this.setSortImgPos();
//it possible that changes of size, has changed header height
if (headerHeight != this.hdr.clientHeight && this._ahgr)
this.setSizes();
this.callEvent("onSetSizes",[]);
};
this.setSizes_clear=function(){
var y=this.hdr.offsetHeight;
var x=this.entBox.offsetWidth;
var y2=y+this.objBox.offsetHeight;
this._topMb.style.top=(y||0)+"px";
this._topMb.style.width=(x+20)+"px";
this._botMb.style.top=(y2-3)+"px";
this._botMb.style.width=(x+20)+"px";
};
/**
* @desc: changes cell width
* @param: [ind] - index of row in grid
* @type: private
* @topic: 4,7
*/
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";
}
}
/**
* @desc: set delimiter character used in list values (default is ",")
* @param: delim - delimiter as string
* @before_init: 1
* @type: public
* @topic: 0
*/
this.setDelimiter=function(delim){
this.delim=delim;
}
/**
* @desc: set width of columns in percents
* @type: public
* @before_init: 1
* @param: wp - list of column width in percents
* @topic: 0,7
*/
this.setInitWidthsP=function(wp){
this.cellWidthType="%";
this.initCellWidth=wp.split(this.delim.replace(/px/gi, ""));
if (!arguments[1]) this._setAutoResize();
}
/**
* @desc:
* @type: private
* @topic: 0
*/
this._setAutoResize=function(){
if (this._realfake) return;
var el = window;
var self = this;
dhtmlxEvent(window,"resize",function(){
window.clearTimeout(self._resize_timer);
if (self._setAutoResize)
self._resize_timer=window.setTimeout(function(){
if (self.setSizes)
self.setSizes();
if (self._fake)
self._fake._correctSplit();
}, 100);
})
}
/**
* @desc: set width of columns in pixels
* @type: public
* @before_init: 1
* @param: wp - list of column width in pixels
* @topic: 0,7
*/
this.setInitWidths=function(wp){
this.cellWidthType="px";
this.initCellWidth=wp.split(this.delim);
if (_isFF){
for (var i = 0; i < this.initCellWidth.length; i++)
if (this.initCellWidth[i] != "*")
this.initCellWidth[i]=parseInt(this.initCellWidth[i]);
}
}
/**
* @desc: set multiline rows support to enabled or disabled state
* @type: public
* @before_init: 1
* @param: state - true or false
* @topic: 0,7
*/
this.enableMultiline=function(state){
this.multiLine=convertStringToBoolean(state);
}
/**
* @desc: set multiselect mode to enabled or disabled state
* @type: public
* @param: state - true or false
* @topic: 0,7
*/
this.enableMultiselect=function(state){
this.selMultiRows=convertStringToBoolean(state);
}
/**
* @desc: set path to grid internal images (sort direction, any images used in editors, checkbox, radiobutton)
* @type: public
* @param: path - url (or relative path) of images folder with closing "/"
* @topic: 0,7
*/
this.setImagePath=function(path){
this.imgURL=path;
}
this.setImagesPath=this.setImagePath;
/**
* @desc: set path to external images used in grid ( tree and img column types )
* @type: public
* @param: path - url (or relative path) of images folder with closing "/"
* @topic: 0,7
*/
this.setIconPath=function(path){
this.iconURL=path;
}
this.setIconsPath=this.setIconPath;
//column_resize:06042008{
/**
* @desc: part of column resize routine
* @type: private
* @param: ev - event
* @topic: 3
*/
this.changeCursorState=function(ev){
var el = ev.target||ev.srcElement;
if (el.tagName != "TD")
el=this.getFirstParentOfType(el, "TD")
if (!el) return;
if ((el.tagName == "TD")&&(this._drsclmn)&&(!this._drsclmn[el._cellIndex]))
return el.style.cursor="default";
var check = (ev.layerX||0)+(((!_isIE)&&(ev.target.tagName == "DIV")) ? el.offsetLeft : 0);
if ((el.offsetWidth-(ev.offsetX||(parseInt(this.getPosition(el, this.hdrBox))-check)*-1)) < (_isOpera?20:10)){
el.style.cursor="E-resize";
}
else{
el.style.cursor="default";
}
if (_isOpera)
this.hdrBox.scrollLeft=this.objBox.scrollLeft;
}
/**
* @desc: part of column resize routine
* @type: private
* @param: ev - event
* @topic: 3
*/
this.startColResize=function(ev){
if (this.resized) this.stopColResize();
this.resized=null;
var el = ev.target||ev.srcElement;
if (el.tagName != "TD")
el=this.getFirstParentOfType(el, "TD")
var x = ev.clientX;
var tabW = this.hdr.offsetWidth;
var startW = parseInt(el.offsetWidth)
if (el.tagName == "TD"&&el.style.cursor != "default"){
if ((this._drsclmn)&&(!this._drsclmn[el._cellIndex]))
return;
self._old_d_mm=document.body.onmousemove;
self._old_d_mu=document.body.onmouseup;
document.body.onmousemove=function(e){
if (self)
self.doColResize(e||window.event, el, startW, x, tabW)
}
document.body.onmouseup=function(){
if (self)
self.stopColResize();
}
}
}
/**
* @desc: part of column resize routine
* @type: private
* @param: ev - event
* @topic: 3
*/
this.stopColResize=function(){
document.body.onmousemove=self._old_d_mm||"";
document.body.onmouseup=self._old_d_mu||"";
this.setSizes();
this.doOnScroll(0, 1)
this.callEvent("onResizeEnd", [this]);
}
/**
* @desc: part of column resize routine
* @param: el - element (column resizing)
* @param: startW - started width
* @param: x - x coordinate to resize from
* @param: tabW - started width of header table
* @type: private
* @topic: 3
*/
this.doColResize=function(ev, el, startW, x, tabW){
el.style.cursor="E-resize";
this.resized=el;
var fcolW = startW+(ev.clientX-x);
var wtabW = tabW+(ev.clientX-x)
if (!(this.callEvent("onResize", [
el._cellIndex,
fcolW,
this
])))
return;
if (_isIE)
this.objBox.scrollLeft=this.hdrBox.scrollLeft;
if (el.colSpan > 1){
var a_sizes = new Array();
for (var i = 0;
i < el.colSpan;
i++)a_sizes[i]=Math.round(fcolW*this.hdr.rows[0].childNodes[el._cellIndexS+i].offsetWidth/el.offsetWidth);
for (var i = 0; i < el.colSpan; i++)
this._setColumnSizeR(el._cellIndexS+i*1, a_sizes[i]);
} else
this._setColumnSizeR(el._cellIndex, fcolW);
this.doOnScroll(0, 1);
this.setSizes();
if (this._fake && this._awdth) this._fake._correctSplit();
}
/**
* @desc: set width of grid columns ( zero row of header and body )
* @type: private
* @topic: 7
*/
this._setColumnSizeR=function(ind, fcolW){
if (fcolW > ((this._drsclmW&&!this._notresize) ? (this._drsclmW[ind]||10) : 10)){
this.obj.rows[0].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-=17;
var pcWidth = Math.round(fcolW / gridWidth*100)
this.cellWidthPC[ind]=pcWidth;
}
if (this.sortImg.style.display!="none")
this.setSortImgPos();
}
}
//}
//sorting:06042008{
/**
* @desc: sets position and visibility of sort arrow
* @param: state - true/false - show/hide image
* @param: ind - index of field
* @param: order - asc/desc - type of image
* @param: row - one based index of header row ( used in multirow headers, top row by default )
* @type: public
* @topic: 7
*/
this.setSortImgState=function(state, ind, order, row){
order=(order||"asc").toLowerCase();
if (!convertStringToBoolean(state)){
this.sortImg.style.display="none";
this.fldSorted=this.r_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].childNodes[ind];
var r = this.hdr.rows[row||1];
if (!r) return;
for (var i = 0; i < r.childNodes.length; i++){
if (r.childNodes[i]._cellIndexS == ind){
this.r_fldSorted=r.childNodes[i];
return this.setSortImgPos();
}
}
return this.setSortImgState(state,ind,order,(row||1)+1);
}
/**
* @desc: sets position and visibility of sort arrow
* @param: ind - index of field
* @param: ind - index of field
* @param: hRowInd - index of row in case of complex header, one-based, optional
* @type: private
* @topic: 7
*/
this.setSortImgPos=function(ind, mode, hRowInd, el){
if (this._hrrar && this._hrrar[this.r_fldSorted?this.r_fldSorted._cellIndex:ind]) return;
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"; //Number(pos[0]+5)+"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"; //-parseInt(this.hdrBox.scrollLeft)
}
}
//}
/**
* @desc: manage activity of the grid.
* @param: fl - true to activate,false to deactivate
* @type: private
* @topic: 1,7
*/
this.setActive=function(fl){
if (arguments.length == 0)
var fl = true;
if (fl == true){
//document.body.onkeydown = new Function("","document.getElementById('"+this.entBox.id+"').grid.doKey()")//
if (globalActiveDHTMLGridObject&&(globalActiveDHTMLGridObject != this)){
globalActiveDHTMLGridObject.editStop();
globalActiveDHTMLGridObject.callEvent("onBlur",[globalActiveDHTMLGridObject]);
}
globalActiveDHTMLGridObject=this;
this.isActive=true;
} else {
this.isActive=false;
this.callEvent("onBlur",[this]);
}
};
/**
* @desc: called on click occured
* @type: private
*/
this._doClick=function(ev){
var selMethod = 0;
var el = this.getFirstParentOfType(_isIE ? ev.srcElement : ev.target, "TD");
if (!el) return;
var fl = true;
//mm
//markers start
if (this.markedCells){
var markMethod = 0;
if (ev.shiftKey||ev.metaKey){
markMethod=1;
}
if (ev.ctrlKey){
markMethod=2;
}
this.doMark(el, markMethod);
return true;
}
//markers end
//mm
if (this.selMultiRows != false){
if (ev.shiftKey && this.row != null && this.selectedRows.length){
selMethod=1;
}
if (ev.ctrlKey||ev.metaKey){
selMethod=2;
}
}
this.doClick(el, fl, selMethod)
};
//context_menu:06042008{
/**
* @desc: called onmousedown inside grid area
* @type: private
*/
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||(_isMacOS&&ev.ctrlKey)){
if (!this.callEvent("onRightClick", [
el.parentNode.idd,
el._cellIndex,
ev
])){
var z = function(e){
(e||event).cancelBubble=true;
return false;
};
(ev.srcElement||ev.target).oncontextmenu=z;
return z(ev);
}
if (this._ctmndx){
if (!(this.callEvent("onBeforeContextMenu", [
el.parentNode.idd,
el._cellIndex,
this
])))
return true;
if (_isIE)
ev.srcElement.oncontextmenu=function(){
event.cancelBubble=true;
return false;
};
if (this._ctmndx.showContextMenu){
var dEl0=window.document.documentElement;
var dEl1=window.document.body;
var corrector = new Array((dEl0.scrollLeft||dEl1.scrollLeft),(dEl0.scrollTop||dEl1.scrollTop));
if (_isIE){
var x= ev.clientX+corrector[0];
var y = ev.clientY+corrector[1];
} else {
var x= ev.pageX;
var y = ev.pageY;
}
this._ctmndx.showContextMenu(x-1,y-1)
this.contextID=this._ctmndx.contextMenuZoneId=el.parentNode.idd+"_"+el._cellIndex;
this._ctmndx._skip_hide=true;
} else {
el.contextMenuId=el.parentNode.idd+"_"+el._cellIndex;
el.contextMenu=this._ctmndx;
el.a=this._ctmndx._contextStart;
el.a(el, ev);
el.a=null;
}
ev.cancelBubble=true;
return false;
}
}
else if (this._ctmndx){
if (this._ctmndx.hideContextMenu)
this._ctmndx.hideContextMenu()
else
this._ctmndx._contextEnd();
}
return true;
}
//}
/**
* @desc: occures on cell click (supports treegrid)
* @param: [el] - cell to click on
* @param: [fl] - true if to call onRowSelect function
* @param: [selMethod] - 0 - simple click, 1 - shift, 2 - ctrl
* @param: show - true/false - scroll row to view, true by defaul
* @type: private
* @topic: 1,2,4,9
*/
this.doClick=function(el, fl, selMethod, show){
if (!this.selMultiRows) selMethod=0; //block programmatical multiselecton if mode not enabled explitly
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"){
if (this.checkEvent("onSelectStateChanged"))
var initial = this.getSelectedId();
var prow = this.row;
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 < this.rowsCol.length; i++)
if ((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;
show = false;
}
}
this.editStop()
if (typeof (el.parentNode.idd) == "undefined")
return true;
if ((!skipRowSelection)&&(!el.parentNode._sRow)){
if (this.callEvent("onBeforeSelect", [
el.parentNode.idd,
psid
])){
if (this.getSelectedRowId() != el.parentNode.idd){
if (selMethod == 0)
this.clearSelection();
this.cell=el;
if ((prow == el.parentNode)&&(this._chRRS))
fl=false;
this.row=el.parentNode;
this.row.className+=" rowselected"
if (this.cell && _isIE && _isIE == 8 ){
//fix incorrect table cell size in IE8 bug
var next = this.cell.nextSibling;
var parent = this.cell.parentNode;
parent.removeChild(this.cell)
parent.insertBefore(this.cell,next);
}
if (this.selectedRows._dhx_find(this.row) == -1)
this.selectedRows[this.selectedRows.length]=this.row;
} else {
this.cell=el;
this.row = el.parentNode;
}
} else fl = false;
}
if (this.cell && 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;
if (fl&& typeof (rid) != "undefined" && cid && !skipRowSelection) {
self.onRowSelectTime=setTimeout(function(){
if (self.callEvent)
self.callEvent("onRowSelect", [
rid,
cid._cellIndex
]);
}, 100);
} else this.callEvent("onRowSelectRSOnly",[rid]);
if (this.checkEvent("onSelectStateChanged")){
var afinal = this.getSelectedId();
if (initial != afinal)
this.callEvent("onSelectStateChanged", [afinal,initial]);
}
}
this.isActive=true;
if (show !== false && this.cell && this.cell.parentNode.idd)
this.moveToVisible(this.cell)
}
/**
* @desc: select all rows in grid, it doesn't fire any events
* @param: edit - switch selected cell to edit mode
* @type: public
* @topic: 1,4
*/
this.selectAll=function(){
this.clearSelection();
var coll = this.rowsBuffer;
//in paging mode, we select only current page
if (this.pagingOn) coll = this.rowsCol;
for (var i = 0; i| "); html.push(" |
",
this.cell.chstate);
}
//}
//ra_excell:04062008{
/**
* @desc: radio editor
* @returns: dhtmlxGrid cell editor object
* @type: public
*/
function eXcell_ra(cell){
this.base=eXcell_ch;
this.base(cell)
this.grid=cell.parentNode.grid;
this.disabledF=function(fl){
if ((fl == true)||(fl == 1))
this.cell.innerHTML=this.cell.innerHTML.replace("radio_chk0.", "radio_chk0_dis.").replace("radio_chk1.",
"radio_chk1_dis.");
else
this.cell.innerHTML=this.cell.innerHTML.replace("radio_chk0_dis.", "radio_chk0.").replace("radio_chk1_dis.",
"radio_chk1.");
}
this.changeState=function(mode){
if (mode===false && this.getValue()==1) return;
if ((!this.grid.isEditable)||(this.cell.parentNode._locked))
return;
if (this.grid.callEvent("onEditCell", [
0,
this.cell.parentNode.idd,
this.cell._cellIndex
]) != false){
this.val=this.getValue()
if (this.val == "1")
this.setValue("0")
else
this.setValue("1")
this.cell.wasChanged=true;
//nb:
this.grid.callEvent("onEditCell", [
1,
this.cell.parentNode.idd,
this.cell._cellIndex
]);
this.grid.callEvent("onCheckbox", [
this.cell.parentNode.idd,
this.cell._cellIndex,
(this.val != '1')
]);
this.grid.callEvent("onCheck", [
this.cell.parentNode.idd,
this.cell._cellIndex,
(this.val != '1')
]);
} else { //preserve editing (not tested thoroughly for this editor)
this.editor=null;
}
}
this.edit=null;
}
eXcell_ra.prototype=new eXcell_ch;
eXcell_ra.prototype.setValue=function(val){
this.cell.style.verticalAlign="middle"; //nb:to center checkbox in line
if (val){
val=val.toString()._dhx_trim();
if ((val == "false")||(val == "0"))
val="";
}
if (val){
if (!this.grid._RaSeCol)
this.grid._RaSeCol=[];
if (this.grid._RaSeCol[this.cell._cellIndex]){
var z = this.grid.cells4(this.grid._RaSeCol[this.cell._cellIndex]);
z.setValue("0")
if (this.grid.rowsAr[z.cell.parentNode.idd])
this.grid.callEvent("onEditCell", [
1,
z.cell.parentNode.idd,
z.cell._cellIndex
]);
}
this.grid._RaSeCol[this.cell._cellIndex]=this.cell;
val="1";
this.cell.chstate="1";
} else {
val="0";
this.cell.chstate="0"
}
this.setCValue("