Add version files and new GIF images for UI components

This commit is contained in:
2025-04-03 06:26:44 +07:00
commit 663c28a2ea
5219 changed files with 772528 additions and 0 deletions

View File

@ -0,0 +1,166 @@
/*
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
*/
dhtmlXGridObject.prototype._process_xmlA=function(xml){
if (!xml.doXPath){
var t = new dtmlXMLLoaderObject(function(){});
if (typeof xml == "string")
t.loadXMLString(xml);
else {
if (xml.responseXML)
t.xmlDoc=xml;
else
t.xmlDoc={};
t.xmlDoc.responseXML=xml;
}
xml=t;
}
this._parsing=true;
var top=xml.getXMLTopNode(this.xml.top)
//#config_from_xml:20092006{
this._parseHead(top);
//#}
var rows=xml.doXPath(this.xml.row,top)
var cr=parseInt(xml.doXPath("//"+this.xml.top)[0].getAttribute("pos")||0);
var total=parseInt(xml.doXPath("//"+this.xml.top)[0].getAttribute("total_count")||0);
if (total && !this.rowsBuffer[total-1]) this.rowsBuffer[total-1]=null;
if (this.isTreeGrid()){
this._get_xml_data = this._get_xml_dataA;
this._process_xml_row = this._process_xml_rowA;
return this._process_tree_xml(xml);
}
for (var i=0; i < rows.length; i++) {
if (this.rowsBuffer[i+cr]) continue;
var id=rows[i].getAttribute("id")||this.uid();
this.rowsBuffer[i+cr]={ idd:id, data:rows[i], _parser: this._process_xml_rowA, _locator:this._get_xml_dataA };
this.rowsAr[id]=rows[i];
//this.callEvent("onRowCreated",[r.idd]);
}
this.render_dataset();
this._parsing=false;
return xml.xmlDoc.responseXML?xml.xmlDoc.responseXML:xml.xmlDoc;
}
dhtmlXGridObject.prototype._process_xmlB=function(xml){
if (!xml.doXPath){
var t = new dtmlXMLLoaderObject(function(){});
if (typeof xml == "string")
t.loadXMLString(xml);
else {
if (xml.responseXML)
t.xmlDoc=xml;
else
t.xmlDoc={};
t.xmlDoc.responseXML=xml;
}
xml=t;
}
this._parsing=true;
var top=xml.getXMLTopNode(this.xml.top)
//#config_from_xml:20092006{
this._parseHead(top);
//#}
var rows=xml.doXPath(this.xml.row,top)
var cr=parseInt(xml.doXPath("//"+this.xml.top)[0].getAttribute("pos")||0);
var total=parseInt(xml.doXPath("//"+this.xml.top)[0].getAttribute("total_count")||0);
if (total && !this.rowsBuffer[total-1]) this.rowsBuffer[total-1]=null;
if (this.isTreeGrid()){
this._get_xml_data = this._get_xml_dataB;
this._process_xml_row = this._process_xml_rowB;
return this._process_tree_xml(xml);
}
for (var i=0; i < rows.length; i++) {
if (this.rowsBuffer[i+cr]) continue;
var id=rows[i].getAttribute("id")||this.uid();
this.rowsBuffer[i+cr]={ idd:id, data:rows[i], _parser: this._process_xml_rowB, _locator:this._get_xml_dataB };
this.rowsAr[id]=rows[i];
//this.callEvent("onRowCreated",[r.idd]);
}
this.render_dataset();
this._parsing=false;
return xml.xmlDoc.responseXML?xml.xmlDoc.responseXML:xml.xmlDoc;
}
dhtmlXGridObject.prototype._process_xml_rowA=function(r,xml){
var strAr = [];
r._attrs=this._xml_attrs(xml);
//load cell data
for(var j=0;j<this.columnIds.length;j++){
var cid=this.columnIds[j];
var cellVal=r._attrs[cid]||"";
if (r.childNodes[j])
r.childNodes[j]._attrs={};
strAr.push(cellVal);
}
//back to common code
this._fillRow(r,(this._c_order?this._swapColumns(strAr):strAr));
return r;
}
dhtmlXGridObject.prototype._get_xml_dataA=function(data,ind){
return data.getAttribute(this.getColumnId(ind));
}
dhtmlXGridObject.prototype._process_xml_rowB=function(r,xml){
var strAr = [];
r._attrs=this._xml_attrs(xml);
//load userdata
if (this._ud_enabled){
var udCol = this.xmlLoader.doXPath("./userdata",xml);
for (var i = udCol.length - 1; i >= 0; i--)
this.setUserData(udCol[i].getAttribute("name"),udCol[i].firstChild?udCol[i].firstChild.data:"");
}
//load cell data
for (var jx=0; jx < xml.childNodes.length; jx++) {
var cellVal=xml.childNodes[jx];
if (!cellVal.tagName) continue;
var j=this.getColIndexById(cellVal.tagName);
if (isNaN(j)) continue;
var exc=cellVal.getAttribute("type");
if (exc)
r.childNodes[j]._cellType=exc;
r.childNodes[j]._attrs=this._xml_attrs(cellVal);
if (cellVal.getAttribute("xmlcontent"))
{}
else if (cellVal.firstChild)
cellVal=cellVal.firstChild.data;
else cellVal="";
strAr[j]=cellVal;
}
for (var i=0; i < r.childNodes.length; i++) {
if (!r.childNodes[i]._attrs) r.childNodes[i]._attrs={};
};
//back to common code
this._fillRow(r,(this._c_order?this._swapColumns(strAr):strAr));
return r;
}
dhtmlXGridObject.prototype._get_xml_dataB=function(data,ind){
var id=this.getColumnId(ind);
data=data.firstChild;
while (true){
if (!data) return "";
if (data.tagName==id) return (data.firstChild?data.firstChild.data:"")
data=data.nextSibling;
}
return "";
}

View File

@ -0,0 +1,808 @@
/*
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: enable/disable drag-and-drop
* @type: public
* @param: mode - enabled/disabled [ can be true/false/temporary_disabled - last value mean that tree can be D-n-D can be switched to true later ]
* @topic: 0
*/
dhtmlXGridObject.prototype.enableDragAndDrop=function(mode){
if (mode=="temporary_disabled"){
this.dADTempOff=false;
mode=true; }
else
this.dADTempOff=true;
this.dragAndDropOff=convertStringToBoolean(mode);
this._drag_validate=true;
if (mode)
this.objBox.ondragstart = function (e) {
(e||event).cancelBubble = true;
return false;
}
};
/**
* @desc: set Drag-And-Drop behavior (child - drop as chils, sibling - drop as sibling
* @type: public
* @param: mode - behavior name (child,sibling,complex)
* @topic: 0
*/
dhtmlXGridObject.prototype.setDragBehavior=function(mode){
this.dadmodec=this.dadmodefix=0;
switch (mode) {
case "child": this.dadmode=0; this._sbmod=false; break;
case "sibling": this.dadmode=1; this._sbmod=false; break;
case "sibling-next": this.dadmode=1; this._sbmod=true; break;
case "complex": this.dadmode=2; this._sbmod=false; break;
case "complex-next": this.dadmode=2; this._sbmod=true; break;
} };
/**
* @desc: switch to mode when draged item, droped in target location in same order as they was in source grid
* @type: public
* @param: mode - true/false to enable/disable mode
* @topic: 0
*/
dhtmlXGridObject.prototype.enableDragOrder=function(mode){
this._dndorder=convertStringToBoolean(mode);
};
dhtmlXGridObject.prototype._checkParent=function(row,ids){
var z=this._h2.get[row.idd].parent;
if (!z.parent) return;
for (var i=0; i<ids.length; i++)
if (ids[i]==z.id) return true;
return this._checkParent(this.rowsAr[z.id],ids);
}
/**
* @desc: create html element for dragging
* @type: private
* @param: htmlObject - html node object
* @topic: 1
*/
dhtmlXGridObject.prototype._createDragNode=function(htmlObject,e){
this.editStop();
if (window.dhtmlDragAndDrop.dragNode) return null;
if (!this.dADTempOff) return null;
htmlObject.parentObject=new Object();
htmlObject.parentObject.treeNod=this;
var text=this.callEvent("onBeforeDrag",[htmlObject.parentNode.idd,htmlObject._cellIndex, e]);
if (!text) return null;
var z=new Array();
//#__pro_feature:21092006{
z=this.getSelectedId();
z=(((z)&&(z!=""))?z.split(this.delim):[]);
var exst=false;
for (var i=0; i<z.length; i++)
if (z[i]==htmlObject.parentNode.idd) exst=true;
if (!exst){
this.selectRow(this.rowsAr[htmlObject.parentNode.idd],false,e.ctrlKey,false);
if (!e.ctrlKey) {
z=[];
}
//#}
z[this.selMultiRows?z.length:0]=htmlObject.parentNode.idd;
//#__pro_feature:21092006{
}
//#}
//remove child in case of treeGrid
if (this.isTreeGrid()){
for (var i=z.length-1; i>=0; i--)
if (this._checkParent(this.rowsAr[z[i]],z)) z.splice(i,1);
}
var self=this;
if (z.length && this._dndorder)
z.sort(function(a,b){ return (self.rowsAr[a].rowIndex>self.rowsAr[b].rowIndex?1:-1); });
var el = this.getFirstParentOfType(_isIE?e.srcElement:e.target,"TD");
if (el) this._dndExtra=el._cellIndex;
this._dragged=new Array();
for (var i=0; i<z.length; i++)
if (this.rowsAr[z[i]]){
this._dragged[this._dragged.length]=this.rowsAr[z[i]];
this.rowsAr[z[i]].treeNod=this;
}
htmlObject.parentObject.parentNode=htmlObject.parentNode;
var dragSpan=document.createElement('div');
dragSpan.innerHTML=(text!==true?text:this.rowToDragElement(htmlObject.parentNode.idd));
dragSpan.style.position="absolute";
dragSpan.className="dragSpanDiv";
return dragSpan;
}
/**
* @desc: create a drag visual marker
* @type: private
*/
dhtmlXGridObject.prototype._createSdrgc=function(){
this._sdrgc=document.createElement("DIV");
this._sdrgc.innerHTML="&nbsp;";
this._sdrgc.className="gridDragLine";
this.objBox.appendChild(this._sdrgc);
}
/**
* @desc: create a drag context object
* @type: private
*/
function dragContext(a,b,c,d,e,f,j,h,k,l){
this.source=a||"grid";
this.target=b||"grid";
this.mode=c||"move";
this.dropmode=d||"child";
this.sid=e||0;
this.tid=f;
this.sobj=j||null;
this.tobj=h||null;
this.sExtra=k||null;
this.tExtra=l||null;
return this;
}
/**
* @desc: check is operation possible
* @type: private
*/
dragContext.prototype.valid=function(){
if (this.sobj!=this.tobj) return true;
if (this.sid==this.tid) return false;
if (this.target=="treeGrid"){
var z=this.tid
while (z = this.tobj.getParentId(z) ){
if (this.sid==z) return false;
}
}
return true;
}
/**
* @desc: close context
* @type: private
*/
dragContext.prototype.close=function(){
this.sobj=null;
this.tobj=null;
}
/**
* @desc: return copy of context
* @type: private
*/
dragContext.prototype.copy=function(){
return new dragContext(this.source,this.target,this.mode,this.dropmode,this.sid,this.tid,this.sobj,this.tobj,this.sExtra,this.tExtra);
}
/**
* @desc: set a lue of context attribute
* @type: private
*/
dragContext.prototype.set=function(a,b){
this[a]=b;
return this;
}
/**
* @desc: generate an Id for new node
* @type: private
*/
dragContext.prototype.uid=function(a,b){
this.nid=this.sid;
while (this.tobj.rowsAr[this.nid])
this.nid=this.nid+((new Date()).valueOf());
return this;
}
/**
* @desc: get data array for grid row
* @type: private
*/
dragContext.prototype.data=function(){
if (this.sobj==this.tobj)
return this.sobj._getRowArray(this.sobj.rowsAr[this.sid]);
if (this.source=="tree")
return this.tobj.treeToGridElement(this.sobj,this.sid,this.tid);
else
return this.tobj.gridToGrid(this.sid,this.sobj,this.tobj);
}
dragContext.prototype.attrs=function(){
if (this.source=="tree")
return {};
else
return this.sobj.rowsAr[this.sid]._attrs;
}
dragContext.prototype.childs=function(){
if (this.source=="treeGrid")
return this.sobj._h2.get[this.sid]._xml_await?this.sobj._h2.get[this.sid].has_kids:null;
return null;
}
/**
* @desc: return parent id for row in context
* @type: private
*/
dragContext.prototype.pid=function(){
if (!this.tid) return 0;
if (!this.tobj._h2) return 0;
if (this.target=="treeGrid")
if (this.dropmode=="child")
return this.tid;
else{
var z=this.tobj.rowsAr[this.tid];
var apid=this.tobj._h2.get[z.idd].parent.id;
if ((this.alfa)&&(this.tobj._sbmod)&&(z.nextSibling)){
var zpid=this.tobj._h2.get[z.nextSibling.idd].parent.id;
if (zpid==this.tid)
return this.tid;
if (zpid!=apid)
return zpid;
}
return apid;
}
}
/**
* @desc: get index of target position
* @type: private
*/
dragContext.prototype.ind=function(){
if (this.tid==window.unknown) return this.tobj.rowsBuffer.length;
if (this.target=="treeGrid"){
if (this.dropmode=="child")
this.tobj.openItem(this.tid);
else
this.tobj.openItem(this.tobj.getParentId(this.tid));
}
var ind=this.tobj.rowsBuffer._dhx_find(this.tobj.rowsAr[this.tid]);
if ((this.alfa)&&(this.tobj._sbmod)&&(this.dropmode=="sibling")){
var z=this.tobj.rowsAr[this.tid];
if ((z.nextSibling)&&(this._h2.get[z.nextSibling.idd].parent.id==this.tid))
return ind+1;
}
return (ind+1+((this.target=="treeGrid" && ind>=0 && this.tobj._h2.get[this.tobj.rowsBuffer[ind].idd].state=="minus")?this.tobj._getOpenLenght(this.tobj.rowsBuffer[ind].idd,0):0));
}
/**
* @desc: get row related image
* @type: private
*/
dragContext.prototype.img=function(){
if ((this.target!="grid")&&(this.sobj._h2))
return this.sobj.getItemImage(this.sid);
else return null;
}
/**
* @desc: return list of rows in context
* @type: private
*/
dragContext.prototype.slist=function(){
var res=new Array();
for (var i=0; i<this.sid.length; i++)
res[res.length]=this.sid[i][(this.source=="tree")?"id":"idd"];
return res.join(",");
}
/**
* @desc: drag entry point
* @type: private
*/
dhtmlXGridObject.prototype._drag=function(sourceHtmlObject,dhtmlObject,targetHtmlObject,lastLanding){
if (this._realfake) return this._fake._drag()
var z=(this.lastLanding)
//close unfinished tasks
if (this._autoOpenTimer) window.clearTimeout(this._autoOpenTimer);
//detect details
var r1=targetHtmlObject.parentNode;
var r2=sourceHtmlObject.parentObject;
//drop on header
if (!r1.idd) { r1.grid=this; this.dadmodefix=0; }
var c=new dragContext(0,0,0,((r1.grid.dadmode==1 || r1.grid.dadmodec)?"sibling":"child"));
if (r2 && r2.childNodes)
c.set("source","tree").set("sobj",r2.treeNod).set("sid",c.sobj._dragged);
else{
if (!r2) return true;
if (r2.treeNod.isTreeGrid && r2.treeNod.isTreeGrid())
c.set("source","treeGrid");
c.set("sobj",r2.treeNod).set("sid",c.sobj._dragged);
}
if (r1.grid.isTreeGrid())
c.set("target","treeGrid");
else
c.set("dropmode","sibling");
c.set("tobj",r1.grid).set("tid",r1.idd);
//#__pro_feature:21092006{
//complex drag mode - adjust tartget element
if (((c.tobj.dadmode==2)&&(c.tobj.dadmodec==1))&&(c.tobj.dadmodefix<0))
if (c.tobj.obj.rows[1].idd!=c.tid) c.tid=r1.previousSibling.idd;
else c.tid=0;
//#}
var el = this.getFirstParentOfType(lastLanding,"TD")
if (el) c.set("tExtra",el._cellIndex);
if (el) c.set("sExtra",c.sobj._dndExtra);
if (c.sobj.dpcpy) c.set("mode","copy");
if (c.tobj._realfake) c.tobj=c.tobj._fake;
if (c.sobj._realfake) c.sobj=c.sobj._fake;
c.tobj._clearMove();
if (r2 && r2.treeNod && r2.treeNod._nonTrivialRow)
r2.treeNod._nonTrivialRow(this,c.tid,c.dropmode,r2);
else {
c.tobj.dragContext=c;
if (!c.tobj.callEvent("onDrag",[c.slist(),c.tid,c.sobj,c.tobj,c.sExtra,c.tExtra])) return c.tobj.dragContext=null;
//all ready, start mantras
var result=new Array();
if (typeof(c.sid)=="object"){
var nc=c.copy();
for (var i=0; i<c.sid.length; i++){
if (!nc.set("alfa",(!i)).set("sid",c.sid[i][(c.source=="tree"?"id":"idd")]).valid()) continue;
nc.tobj._dragRoutine(nc);
if (nc.target=="treeGrid" && nc.dropmode == "child") nc.tobj.openItem(nc.tid);
result[result.length]=nc.nid;
nc.set("dropmode","sibling").set("tid",nc.nid);
}
nc.close();
}
else
c.tobj._dragRoutine(c);
//finish math if any awaiting
if (c.tobj.laterLink) c.tobj.laterLink();
//destroy context
c.tobj.callEvent("onDrop",[c.slist(),c.tid,result.join(","),c.sobj,c.tobj,c.sExtra,c.tExtra]);
}
c.tobj.dragContext=null;
c.close();
}
/**
* @desc: context drag routine
* @type: private
*/
dhtmlXGridObject.prototype._dragRoutine=function(c){
if ((c.sobj==c.tobj)&&(c.source=="grid")&&(c.mode=="move")&&!this._fake){
//special case for moving rows in same grid
if (c.sobj._dndProblematic) return;
var fr=c.sobj.rowsAr[c.sid];
var bind=c.sobj.rowsCol._dhx_find(fr);
c.sobj.rowsCol._dhx_removeAt(c.sobj.rowsCol._dhx_find(fr));
c.sobj.rowsBuffer._dhx_removeAt(c.sobj.rowsBuffer._dhx_find(fr));
c.sobj.rowsBuffer._dhx_insertAt(c.ind(),fr);
if (c.tobj._fake){
c.tobj._fake.rowsCol._dhx_removeAt(bind);
var tr=c.tobj._fake.rowsAr[c.sid];
tr.parentNode.removeChild(tr);
}
c.sobj._insertRowAt(fr,c.ind());
c.nid=c.sid;
c.sobj.callEvent("onGridReconstructed",[]);
return;
}
var new_row;
if (this._h2 && typeof c.tid !="undefined" && c.dropmode=="sibling" && (this._sbmod || c.tid)){
if (c.alfa && this._sbmod && this._h2.get[c.tid].childs.length){
this.openItem(c.tid)
new_row=c.uid().tobj.addRowBefore(c.nid,c.data(),this._h2.get[c.tid].childs[0].id,c.img(),c.childs());
}
else
new_row=c.uid().tobj.addRowAfter(c.nid,c.data(),c.tid,c.img(),c.childs());
}
else
new_row=c.uid().tobj.addRow(c.nid,c.data(),c.ind(),c.pid(),c.img(),c.childs());
new_row._attrs = c.attrs();
if (c.source=="tree"){
this.callEvent("onRowAdded",[c.nid]);
var sn=c.sobj._globalIdStorageFind(c.sid);
if (sn.childsCount){
var nc=c.copy().set("tid",c.nid).set("dropmode",c.target=="grid"?"sibling":"child");
for(var j=0;j<sn.childsCount;j++){
c.tobj._dragRoutine(nc.set("sid",sn.childNodes[j].id));
if (c.mode=="move") j--;
}
nc.close();
}
}
else{
c.tobj._copyUserData(c);
this.callEvent("onRowAdded",[c.nid]);
if ((c.source=="treeGrid")){
if (c.sobj==c.tobj) new_row._xml=c.sobj.rowsAr[c.sid]._xml;
var snc=c.sobj._h2.get[c.sid];
if ((snc)&&(snc.childs.length)){
var nc=c.copy().set("tid",c.nid);
if(c.target=="grid")
nc.set("dropmode","sibling");
else {
nc.tobj.openItem(c.tid);
nc.set("dropmode","child");
}
var l=snc.childs.length;
for(var j=0;j<l;j++){
c.sobj.render_row_tree(null,snc.childs[j].id);
c.tobj._dragRoutine(nc.set("sid",snc.childs[j].id));
if (l!=snc.childs.length) { j--; l=snc.childs.length; }
}
nc.close();
}
}
}
if (c.mode=="move"){
c.sobj[(c.source=="tree")?"deleteItem":"deleteRow"](c.sid);
if ((c.sobj==c.tobj)&&(!c.tobj.rowsAr[c.sid])) {
c.tobj.changeRowId(c.nid,c.sid);
c.nid=c.sid;
}
}
}
/**
* @desc: redefine this method in your code to define how grid row values should be used in another grid
* @param: rowId - id of draged row
* @param: sgrid - source grid object
* @param: tgrid - target grid object
* @returns: array of values for cells in target grid row
* @type: public
* @topic: 7
*/
dhtmlXGridObject.prototype.gridToGrid = function(rowId,sgrid,tgrid){
var z=new Array();
for (var i=0; i<sgrid.hdr.rows[0].cells.length; i++)
z[i]=sgrid.cells(rowId,i).getValue();
return z;
}
/**
* @desc: check if d-n-d is in allowed rules
* @type: private
*/
dhtmlXGridObject.prototype.checkParentLine=function(node,id){
if ((!this._h2)||(!id)||(!node)) return false;
if (node.id==id) return true;
else return this.checkParentLine(node.parent,id);
}
/**
* @desc: called when drag moved over landing
* @type: private
*/
dhtmlXGridObject.prototype._dragIn=function(htmlObject,shtmlObject,x,y){
if (!this.dADTempOff) return 0;
var tree=this.isTreeGrid();
var obj=shtmlObject.parentNode.idd?shtmlObject.parentNode:shtmlObject.parentObject;
if (this._drag_validate){
if(htmlObject.parentNode==shtmlObject.parentNode)
return 0;
if ((tree)&&(this==obj.grid)&&((this.checkParentLine(this._h2.get[htmlObject.parentNode.idd],shtmlObject.parentNode.idd))))
return 0;
}
if (!this.callEvent("onDragIn",[obj.idd||obj.id,htmlObject.parentNode.idd,obj.grid||obj.treeNod,(htmlObject.grid||htmlObject.parentNode.grid)]))
return this._setMove(htmlObject,x,y,true);
this._setMove(htmlObject,x,y);
if ((tree)&&(htmlObject.parentNode.expand!="")){
this._autoOpenTimer=window.setTimeout(new callerFunction(this._autoOpenItem,this),1000);
this._autoOpenId=htmlObject.parentNode.idd;
}
else
if (this._autoOpenTimer) window.clearTimeout(this._autoOpenTimer);
return htmlObject;
}
/**
* @desc: open item on timeout
* @type: private
*/
dhtmlXGridObject.prototype._autoOpenItem=function(e,gridObject){
gridObject.openItem(gridObject._autoOpenId);
}
/**
* @desc: called on onmouseout event , when drag out landing zone
* @type: private
*/
dhtmlXGridObject.prototype._dragOut=function(htmlObject){
this._clearMove();
var obj=htmlObject.parentNode.parentObject?htmlObject.parentObject.id:htmlObject.parentNode.idd;
this.callEvent("onDragOut",[obj]);
if (this._autoOpenTimer) window.clearTimeout(this._autoOpenTimer);
}
/**
* @desc: set visual effect for moving row over landing
* @type: private
*/
dhtmlXGridObject.prototype._setMove=function(htmlObject,x,y,skip){
if (!htmlObject.parentNode.idd) return;
var a1=getAbsoluteTop(htmlObject);
var a2=getAbsoluteTop(this.objBox);
//scroll down
if ( (a1-a2)>(parseInt(this.objBox.offsetHeight)-50) )
this.objBox.scrollTop=parseInt(this.objBox.scrollTop)+20;
//scroll top
if ( (a1-a2+parseInt(this.objBox.scrollTop))<(parseInt(this.objBox.scrollTop)+30) )
this.objBox.scrollTop=parseInt(this.objBox.scrollTop)-20;
if (skip) return 0;
if (this.dadmode==2)
{
var z=y-a1+(document.body.scrollTop||document.documentElement.scrollTop)-2-htmlObject.offsetHeight/2;
if ((Math.abs(z)-htmlObject.offsetHeight/6)>0)
{
this.dadmodec=1;
//sibbling zone
if (z<0) this.dadmodefix=-1; else this.dadmodefix=1;
}
else this.dadmodec=0;
}
else
this.dadmodec=this.dadmode;
if (this.dadmodec){
if (!this._sdrgc) this._createSdrgc();
this._sdrgc.style.display="block";
this._sdrgc.style.top=a1-a2+parseInt(this.objBox.scrollTop)+((this.dadmodefix>=0)?htmlObject.offsetHeight:0)+"px";
}
else{
this._llSelD=htmlObject;
if (htmlObject.parentNode.tagName=="TR")
for (var i=0; i<htmlObject.parentNode.childNodes.length; i++)
{
var z= htmlObject.parentNode.childNodes[i];
z._bgCol=z.style.backgroundColor;
z.style.backgroundColor="#FFCCCC";
}
}
}
/**
* @desc: remove all visual effects
* @type: private
*/
dhtmlXGridObject.prototype._clearMove=function(){
if (this._sdrgc) this._sdrgc.style.display="none";
if ((this._llSelD)&&(this._llSelD.parentNode.tagName=="TR")){
var coll = this._llSelD.parentNode.childNodes;
for (var i=0; i<coll.length; i++)
coll[i].style.backgroundColor=coll[i]._bgCol;
}
this._llSelD=null;
}
/**
* @desc: redefine this method in your code to define how grid row values should be displaied while draging
* @param: gridRowId - id of grid row
* @returns: html string representing dragging row
* @type: public
* @topic: 7
*/
dhtmlXGridObject.prototype.rowToDragElement=function(gridRowId){
var out=this.cells(gridRowId,0).getValue();
return out;
}
/**
* @desc: copy user data for row
* @type: private
*/
dhtmlXGridObject.prototype._copyUserData = function(c){
if(!c.tobj.UserData[c.nid] || c.tobj!=c.sobj)
c.tobj.UserData[c.nid] = new Hashtable();
else return;
var z1 = c.sobj.UserData[c.sid];
var z2 = c.tobj.UserData[c.nid];
if (z1) {
z2.keys = z2.keys.concat(z1.keys);
z2.values = z2.values.concat(z1.values);
}
}
/**
* @desc: move row
* @type: public
* @param: rowId - source row Id
* @param: mode - moving mode (up,down,row_sibling)
* @param: targetId - target row in row_sibling mode
* @param: targetGrid - used for moving between grids (optional)
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.moveRow=function(rowId,mode,targetId,targetGrid){
switch(mode){
case "row_sibling":
this.moveRowTo(rowId,targetId,"move","sibling",this,targetGrid);
break;
case "up":
this.moveRowUp(rowId);
break;
case "down":
this.moveRowDown(rowId);
break;
}
}
//#__pro_feature:21092006{
/**
* @desc: move rows from grid to tree
* @param: tree - object of tree
* @param: targetObject - target node of tree
* @param: beforeNode - anchor node of tree
* @param: itemObject - dragged node
* @param: z2 - flag of recursion
* @type: private
* @edition: Professional
* @topic: 7
*/
dhtmlXGridObject.prototype._nonTrivialNode=function(tree,targetObject,beforeNode,itemObject,z2)
{
if ((tree.callEvent)&&(!z2))
if (!tree.callEvent("onDrag",[itemObject.idd,targetObject.id,(beforeNode?beforeNode.id:null),this,tree])) return false;
var gridRowId = itemObject.idd;
var treeNodeId = gridRowId;
while (tree._idpull[treeNodeId]) treeNodeId+=(new Date()).getMilliseconds().toString();
var img=(this.isTreeGrid()?this.getItemImage(gridRowId):"")
if (beforeNode){
for (i=0; i<targetObject.childsCount; i++)
if (targetObject.childNodes[i]==beforeNode) break;
if (i!=0)
beforeNode=targetObject.childNodes[i-1];
else{
st="TOP";
beforeNode="";
}
}
var newone=tree._attachChildNode(targetObject,treeNodeId,this.gridToTreeElement(tree,treeNodeId,gridRowId),"",img,img,img,"","",beforeNode);
if (this._h2){
var akids=this._h2.get[gridRowId];
if (akids.childs.length)
for (var i=0; i<akids.childs.length; i++){
this._nonTrivialNode(tree,newone,0,this.rowsAr[akids.childs[i].id],1);
if (!this.dpcpy) i--;
}
}
if (!this.dpcpy) this.deleteRow(gridRowId);
if ((tree.callEvent)&&(!z2))
tree.callEvent("onDrop",[treeNodeId,targetObject.id,(beforeNode?beforeNode.id:null),this,tree]);
}
/**
* @desc: redefine this method in your code to define how grid row values should be used in tree (using input parameters you can change id of new tree node, set label, set userdata blocks etc.).
* @param: treeObj - object of tree
* @param: treeNodeId - id of node created in tree
* @param: gridRowId - id of grid row
* @returns: if true, then grid row will be moved to tree, else - copied
* @type: public
* @edition: Professional
* @topic: 7
*/
dhtmlXGridObject.prototype.gridToTreeElement = function(treeObj,treeNodeId,gridRowId){
return this.cells(gridRowId,0).getValue();
}
/**
* @desc: redefine this method in your code to define how tree node values should be used in grid (using input parameters you can change id of new row, values for cells, userdata blocks etc.).
* @param: treeObj - object of tree
* @param: treeNodeId - id of node created in tree
* @param: gridRowId - id of grid row
* @returns: if true, then tree node should be moved to grid, else - copied
* @type: public
* @edition: Professional
* @topic: 7
*/
dhtmlXGridObject.prototype.treeToGridElement = function(treeObj,treeNodeId,gridRowId){
var w=new Array();
var z=this.cellType._dhx_find("tree");
if (z==-1) z=0;
for(var i=0;i<this.getColumnCount();i++)
w[w.length]=(i!=z)?(treeObj.getUserData(treeNodeId,this.getColumnId(i))||""):treeObj.getItemText(treeNodeId);
return w;
}
/**
* @desc: move row
* @type: public
* @param: srowId - source row Id
* @param: trowId - target row Id
* @param: mode - move or copy
* @param: dropmode - sibling or child
* @param: sourceGrid - target row in row_sibling mode
* @param: targetGrid - used for moving between grids (optional)
* @returns: moved item ID
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.moveRowTo=function(srowId,trowId,mode,dropmode,sourceGrid,targetGrid){
var c=new dragContext((sourceGrid||this).isTreeGrid()?"treeGrid":"grid",(targetGrid||this).isTreeGrid()?"treeGrid":"grid",mode,dropmode||"sibling",srowId,trowId,sourceGrid||this,targetGrid||this);
c.tobj._dragRoutine(c);
c.close();
return c.nid;
}
/**
* @desc: enable drag without removing (copy instead of move)
* @beforeInit: 1
* @param: mode - 1 - on, 0 - off;
* @type: public
* @edition:Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableMercyDrag=function(mode){ this.dpcpy=convertStringToBoolean(mode); };
//#}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,253 @@
/*
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
*/
dhtmlXGridObject.prototype.toPDF=function(url,mode,header,footer,rows,target){
var save_sel = {
row: this.getSelectedRowId(),
col: this.getSelectedCellIndex()
};
if (save_sel.row === null || save_sel.col === -1)
save_sel = false;
else {
var el = this.cells(save_sel.row, save_sel.col).cell;
el.parentNode.className = el.parentNode.className.replace(' rowselected', '');
el.className = el.className.replace(' cellselected', '');
save_sel.el = el;
}
mode = mode || "color";
var full_color = mode == "full_color";
var grid = this;
grid._asCDATA = true;
if (typeof(target) === 'undefined')
this.target = " target=\"_blank\"";
else
this.target = target;
eXcell_ch.prototype.getContent = function(){
return this.getValue();
};
eXcell_ra.prototype.getContent = function(){
return this.getValue();
};
function xml_top(profile) {
var spans = [];
for (var i=1; i<grid.hdr.rows.length; i++){
spans[i]=[];
for (var j=0; j<grid._cCount; j++){
var cell = grid.hdr.rows[i].childNodes[j];
if (!spans[i][j])
spans[i][j]=[0,0];
if (cell)
spans[i][cell._cellIndexS]=[cell.colSpan, cell.rowSpan];
}
}
var xml = "<rows profile='"+profile+"'";
if (header)
xml+=" header='"+header+"'";
if (footer)
xml+=" footer='"+footer+"'";
xml+="><head>"+grid._serialiseExportConfig(spans).replace(/^<head/,"<columns").replace(/head>$/,"columns>");
for (var i=2; i < grid.hdr.rows.length; i++) {
var empty_cols = 0;
var row = grid.hdr.rows[i];
var cxml="";
for (var j=0; j < grid._cCount; j++) {
if ((grid._srClmn && !grid._srClmn[j]) || (grid._hrrar[j] && ( !grid._fake || j >= grid._fake.hdrLabels.length))) {
empty_cols++;
continue;
}
var s = spans[i][j];
var rspan = (( s[0] && s[0] > 1 ) ? ' colspan="'+s[0]+'" ' : "");
if (s[1] && s[1] > 1){
rspan+=' rowspan="'+s[1]+'" ';
empty_cols = -1;
}
var val = "";
//split mode
var frow = row;
if (grid._fake && j < grid._fake._cCount)
frow = grid._fake.hdr.rows[i];
for (var k=0; k<frow.cells.length; k++){
if (frow.cells[k]._cellIndexS==j) {
if (frow.cells[k].getElementsByTagName("SELECT").length)
val="";
else
val = _isIE?frow.cells[k].innerText:frow.cells[k].textContent;
val=val.replace(/[ \n\r\t\xA0]+/," ");
break;
}
}
if (!val || val==" ") empty_cols++;
cxml+="<column"+rspan+"><![CDATA["+val+"]]></column>";
};
if (empty_cols != grid._cCount)
xml+="\n<columns>"+cxml+"</columns>";
};
xml+="</head>\n";
xml+=xml_footer();
return xml;
};
function xml_body() {
var xml =[];
if (rows)
for (var i=0; i<rows.length; i++)
xml.push(xml_row(grid.getRowIndex(rows[i])));
else
for (var i=0; i<grid.getRowsNum(); i++)
xml.push(xml_row(i));
return xml.join("\n");
}
function xml_footer() {
var xml =["<foot>"];
if (!grid.ftr) return "";
for (var i=1; i < grid.ftr.rows.length; i++) {
xml.push("<columns>");
var row = grid.ftr.rows[i];
for (var j=0; j < grid._cCount; j++){
if (grid._srClmn && !grid._srClmn[j]) continue;
if (grid._hrrar[j] && ( !grid._fake || j >= grid._fake.hdrLabels.length)) continue;
for (var k=0; k<row.cells.length; k++){
var val = "";
var span = "";
if (row.cells[k]._cellIndexS==j) {
val = _isIE?row.cells[k].innerText:row.cells[k].textContent;
val=val.replace(/[ \n\r\t\xA0]+/," ");
if (row.cells[k].colSpan && row.cells[k].colSpan!=1)
span = " colspan='"+row.cells[k].colSpan+"' ";
if (row.cells[k].rowSpan && row.cells[k].rowSpan!=1)
span = " rowspan='"+row.cells[k].rowSpan+"' ";
break;
}
}
xml.push("<column"+span+"><![CDATA["+val+"]]></column>");
}
xml.push("</columns>");
};
xml.push("</foot>");
return xml.join("\n");
};
function get_style(node, style){
return (window.getComputedStyle?(window.getComputedStyle(node, null)[style]):(node.currentStyle?node.currentStyle[style]:null))||"";
};
function xml_row(ind){
if (!grid.rowsBuffer[ind]) return "";
var r = grid.render_row(ind);
if (r.style.display=="none") return "";
var level = grid.isTreeGrid() ? ' level="' + grid.getLevel(r.idd) + '"' : '';
var xml = "<row" + level + ">";
for (var i=0; i < grid._cCount; i++) {
if (((!grid._srClmn)||(grid._srClmn[i]))&&(!grid._hrrar[i] || ( grid._fake && i < grid._fake.hdrLabels.length))){
var cell = grid.cells(r.idd, i);
if (full_color){
var text_color = get_style(cell.cell,"color");
var bg_color = get_style(cell.cell,"backgroundColor");
var bold = get_style(cell.cell, "font-weight") || get_style(cell.cell, "fontWeight");
var italic = get_style(cell.cell, "font-style") || get_style(cell.cell, "fontStyle");
var align = get_style(cell.cell, "text-align") || get_style(cell.cell, "textAlign");
var font = get_style(cell.cell, "font-family") || get_style(cell.cell, "fontFamily");
if (bg_color == "transparent" || bg_color == "rgba(0, 0, 0, 0)") bg_color = "rgb(255,255,255)";
xml+="<cell bgColor='"+bg_color+"' textColor='" + text_color + "' bold='" + bold + "' italic='" + italic + "' align='"+align+"' font='" + font + "'>";
} else
xml+="<cell>";
xml+="<![CDATA["+(cell.getContent?cell.getContent():cell.getTitle())+"]]></cell>";
}
};
return xml+"</row>";
}
function xml_end(){
var xml = "</rows>";
return xml;
}
var d=document.createElement("div");
d.style.display="none";
document.body.appendChild(d);
var uid = "form_"+grid.uid();
d.innerHTML = '<form id="'+uid+'" method="post" action="'+url+'" accept-charset="utf-8" enctype="application/x-www-form-urlencoded"' + this.target + '><input type="hidden" name="grid_xml" id="grid_xml"/> </form>';
document.getElementById(uid).firstChild.value = encodeURIComponent(xml_top(mode).replace("\u2013", "-") + xml_body() + xml_end());
document.getElementById(uid).submit();
d.parentNode.removeChild(d);
grid = null;
if (save_sel) {
save_sel.el.parentNode.className += ' rowselected';
save_sel.el.className += ' cellselected';
};
save_sel = null;
};
dhtmlXGridObject.prototype._serialiseExportConfig=function(spans){
function xmlentities(str) {
if (typeof(str)!=='string') return str;
str = str.replace(/&/g, "&amp;");
str = str.replace(/"/g, "&quot;");
str = str.replace(/'/g, "&apos;");
str = str.replace(/</g, "&lt;");
str = str.replace(/>/g, "&gt;");
return str;
}
var out = "<head>";
for (var i = 0; i < this.hdr.rows[0].cells.length; i++){
if (this._srClmn && !this._srClmn[i]) continue;
if (this._hrrar[i] && ( !this._fake || i >= this._fake.hdrLabels.length)) continue;
var sort = this.fldSort[i];
if (sort == "cus"){
sort = this._customSorts[i].toString();
sort=sort.replace(/function[\ ]*/,"").replace(/\([^\f]*/,"");
}
var s = spans[1][i];
var rpans = (( s[1] && s[1] > 1 ) ? ' rowspan="'+s[1]+'" ' : "")+(( s[0] && s[0] > 1 ) ? ' colspan="'+s[0]+'" ' : "");
out+="<column "+rpans+" width='"+this.getColWidth(i)+"' align='"+this.cellAlign[i]+"' type='"+this.cellType[i] + "' hidden='" + ((this.isColumnHidden && this.isColumnHidden(i)) ? 'true' : 'false')
+"' sort='"+(sort||"na")+"' color='"+(this.columnColor[i]||"")+"'"
+(this.columnIds[i]
? (" id='"+this.columnIds[i]+"'")
: "")+">";
if (this._asCDATA)
out+="<![CDATA["+this.getHeaderCol(i)+"]]>";
else
out+=this.getHeaderCol(i);
var z = this.combos[i]?this.getCombo(i):null;
if (z)
for (var j = 0; j < z.keys.length; j++)out+="<option value='"+xmlentities(z.keys[j])+"'><![CDATA["+z.values[j]+"]]></option>";
out+="</column>";
}
return out+="</head>";
};
if (window.eXcell_sub_row_grid)
window.eXcell_sub_row_grid.prototype.getContent=function(){ return ""; };
dhtmlXGridObject.prototype.toExcel = function(url,mode,header,footer,rows) {
if (!document.getElementById('ifr')) {
var ifr = document.createElement('iframe');
ifr.style.display = 'none';
ifr.setAttribute('name', 'dhx_export_iframe');
ifr.setAttribute('src', '');
ifr.setAttribute('id', 'dhx_export_iframe');
document.body.appendChild(ifr);
}
var target = " target=\"dhx_export_iframe\"";
this.toPDF(url,mode,header,footer,rows,target);
}

View File

@ -0,0 +1,56 @@
/*
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
*/
//next function switch grid between fast and normal operation modes
//limitation - will not work for paging|smart_rendering|dynamic|split modes, most events will not be generated
/**
* @desc: start fast operation mode, in such mode events are not generated, some time consuming actions applied only once, which allow to increase performance
* @type: public
* @topic: 0
*/
dhtmlXGridObject.prototype.startFastOperations = function(){
this._disF=["setSizes","callEvent","_fixAlterCss","cells4","forEachRow", "_correctMonolite"];
this._disA=[];
for (var i = this._disF.length - 1; i >= 0; i--){
this._disA[i]=this[this._disF[i]]; this[this._disF[i]]=function(){return true};
};
this._cellCache=[];
this.cells4=function(cell){
var c=this._cellCache[cell._cellIndex]
if (!c){
c=this._cellCache[cell._cellIndex]=this._disA[3].apply(this,[cell]);
c.destructor=function(){return true;}
c.setCValue=function(val){c.cell.innerHTML=val;}
}
c.cell=cell;
c.combo=cell._combo||this.combos[cell._cellIndex];
return c;
}
}
/**
* @desc: turn off fast operation mode, need to be executed to normalize view.
* @type: public
* @topic: 0
*/
dhtmlXGridObject.prototype.stopFastOperations = function(){
if (!this._disF) return;
for (var i = this._disF.length - 1; i >= 0; i--){
this[this._disF[i]]=this._disA[i];
};
if (this._correctMonolite)
this._correctMonolite();
this.setSizes();
this.callEvent("onGridReconstructed",[]);
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,626 @@
/*
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
*/
//please beware that function started from _in_header_ must not be obfuscated
/**
* @desc: filter grid by mask
* @type: public
* @param: column - {number} zero based index of column
* @param: value - {string} filtering mask
* @param: preserve - {bool} filter current or initial state ( false by default )
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.filterBy=function(column, value, preserve){
if (this.isTreeGrid()) return this.filterTreeBy(column, value, preserve);
if (this._f_rowsBuffer){
if (!preserve){
this.rowsBuffer=dhtmlxArray([].concat(this._f_rowsBuffer));
if (this._fake) this._fake.rowsBuffer=this.rowsBuffer;
}
} else
this._f_rowsBuffer=[].concat(this.rowsBuffer); //backup copy
if (!this.rowsBuffer.length) return;
var d=true;
this.dma(true)
if (typeof(column)=="object")
for (var j=0; j<value.length; j++)
this._filterA(column[j],value[j]);
else
this._filterA(column,value);
this.dma(false)
if (this.pagingOn && this.rowsBuffer.length/this.rowsBufferOutSize < (this.currentPage-1)) this.changePage(0);
this._reset_view();
this.callEvent("onGridReconstructed",[])
}
dhtmlXGridObject.prototype._filterA=function(column,value){
if (value=="") return;
var d=true;
if (typeof(value)=="function") d=false;
else value=(value||"").toString().toLowerCase();
if (!this.rowsBuffer.length) return;
for (var i=this.rowsBuffer.length-1; i>=0; i--)
if (d?(this._get_cell_value(this.rowsBuffer[i],column).toString().toLowerCase().indexOf(value)==-1):(!value.call(this, this._get_cell_value(this.rowsBuffer[i],column),this.rowsBuffer[i].idd)))
this.rowsBuffer.splice(i,1);//filter row
}
dhtmlXGridObject.prototype.getFilterElement=function(index){
if (!this.filters) return;
for (var i=0; i < this.filters.length; i++) {
if (this.filters[i][1]==index)
return (this.filters[i][0].combo||this.filters[i][0]);
};
return null;
}
/**
* @desc: get all possible values in column
* @type: public
* @param: column - {number} zero based index of column
* @returns: {array} array of all possible values in column
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.collectValues=function(column){
var value=this.callEvent("onCollectValues",[column]);
if (value!==true) return value;
if (this.isTreeGrid()) return this.collectTreeValues(column);
this.dma(true)
this._build_m_order();
column=this._m_order?this._m_order[column]:column;
var c={}; var f=[];
var col=this._f_rowsBuffer||this.rowsBuffer;
for (var i=0; i<col.length; i++){
var val=this._get_cell_value(col[i],column);
if (val && (!col[i]._childIndexes || col[i]._childIndexes[column]!=col[i]._childIndexes[column-1])) c[val]=true;
}
this.dma(false);
var vals= (this.combos[column]||(this._col_combos?this._col_combos[column]:false));
for (var d in c)
if (c[d]===true){
if(vals){
if(vals.get&&vals.get(d)){
d = vals.get(d);
}
else if(vals.getOption&&vals.getOption(d)){
d = vals.getOption(d).text;
}
}
f.push(d);
}
return f.sort();
}
dhtmlXGridObject.prototype._build_m_order=function(){
if (this._c_order){
this._m_order=[]
for (var i=0; i < this._c_order.length; i++) {
this._m_order[this._c_order[i]]=i;
};
}
}
/**
* @desc: force grid filtering by registered inputs ( created by # starting shortcuts, or by makeFilter function )
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.filterByAll=function(){
var a=[];
var b=[];
this._build_m_order();
for (var i=0; i<this.filters.length; i++){
var ind=this._m_order?this._m_order[this.filters[i][1]]:this.filters[i][1];
if (ind >= this._cCount) continue;
b.push(ind);
var val=this.filters[i][0].old_value=this.filters[i][0].value;
if (this.filters[i][0]._filter)
val = this.filters[i][0]._filter();
var vals;
if (typeof val != "function" && (vals=(this.combos[ind]||(this._col_combos?this._col_combos[ind]:false)))){
if(vals.values){
ind=vals.values._dhx_find(val);
val=(ind==-1)?val:vals.keys[ind];
}
else if(vals.getOptionByLabel){
val=(vals.getOptionByLabel(val)?vals.getOptionByLabel(val).value:val);
}
}
a.push(val);
}
if (!this.callEvent("onFilterStart",[b,a])) return;
this.filterBy(b,a);
if (this._cssEven) this._fixAlterCss();
this.callEvent("onFilterEnd",[this.filters]);
if (this._f_rowsBuffer && this.rowsBuffer.length == this._f_rowsBuffer.length)
this._f_rowsBuffer = null;
}
/**
* @desc: create a filter from any input element (text filter), select (dropdown) or DIV (combobox based on dhtmlxCombo)
* @type: public
* @param: id - {string|object} input id or input html object
* @param: column - {number} index of column
* @param: preserve - {bool} filter current state or initial one ( false by default )
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.makeFilter=function(id,column,preserve){
if (!this.filters) this.filters=[];
if (typeof(id)!="object")
id=document.getElementById(id);
if(!id) return;
var self=this;
if (!id.style.width) id.style.width = "90%";
if (id.tagName=='SELECT'){
this.filters.push([id,column]);
this._loadSelectOptins(id,column);
id.onchange=function(){
self.filterByAll();
}
if(_isIE)
id.style.marginTop="1px";
this.attachEvent("onEditCell",function(stage,a,ind){
this._build_m_order();
if (stage==2 && this.filters && ( this._m_order?(ind==this._m_order[column]):(ind==column) ))
this._loadSelectOptins(id,column);
return true;
});
}
else if (id.tagName=='INPUT'){
this.filters.push([id,column]);
id.old_value = id.value='';
id.onkeydown=function(){
if (this._timer) window.clearTimeout(this._timer);
this._timer=window.setTimeout(function(){
if (id.value != id.old_value){
self.filterByAll();
id.old_value=id.value;
}
},500);
};
}
else if (id.tagName=='DIV' && id.className=="combo"){
this.filters.push([id,column]);
id.style.padding="0px";id.style.margin="0px";
if (!window.dhx_globalImgPath) window.dhx_globalImgPath=this.imgURL;
var z=new dhtmlXCombo(id,"_filter","90%");
z.filterSelfA=z.filterSelf;
z.filterSelf=function(){
if (this.getSelectedIndex()==0) this.setComboText("");
this.filterSelfA.apply(this,arguments);
this.optionsArr[0].hide(false);
}
z.enableFilteringMode(true);
id.combo=z;
id.value="";
this._loadComboOptins(id,column);
z.attachEvent("onChange",function(){
id.value=z.getSelectedValue();
if (id.value === null) id.value = "";
self.filterByAll();
});
}
if (id.parentNode)
id.parentNode.className+=" filter";
this._filters_ready(); //set event handlers
}
/**
* @desc: find cell in grid by value
* @param: value - search string
* @param: c_ind - index of column to search in (optional. if not specified, then search everywhere)
* @param: count - count of results to return
* @edition: Professional
* @returns: array each member of which contains array with row ID and cell index
* @type: public
*/
dhtmlXGridObject.prototype.findCell=function(value, c_ind, count, compare){
var compare = compare || (function(master, check){
return check.toString().toLowerCase().indexOf(master) != -1;
});
if (compare === true)
compare = function(master, check){ return check.toString().toLowerCase() == master; };
var res = new Array();
value=value.toString().toLowerCase();
if (typeof count != "number") count = count?1:0;
if (!this.rowsBuffer.length)
return res;
for (var i = (c_ind||0); i < this._cCount; i++){
if (this._h2)
this._h2.forEachChild(0,function(el){
if (count && res.length==count) return res;
if (compare(value, this._get_cell_value(el.buff,i))){
res.push([el.id,i]);
}
},this)
else
for (var j=0; j < this.rowsBuffer.length; j++)
if (compare(value, this._get_cell_value(this.rowsBuffer[j],i))){
res.push([this.rowsBuffer[j].idd,i]);
if (count && res.length==count) return res;
}
if (typeof (c_ind) != "undefined")
return res;
}
return res;
}
/**
* @desc: create a search box (set selection to the row with found value) from any input
* @type: public
* @param: id - {string|object} input id or input html object
* @param: column - {number} index of column
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.makeSearch=function(id,column,strict){
if (typeof(id)!="object")
id=document.getElementById(id);
if(!id) return;
var self=this;
if (id.tagName=='INPUT'){
id.onkeypress=function(){
if (this._timer) window.clearTimeout(this._timer);
this._timer=window.setTimeout(function(){
if (id.value=="") return;
var z=self.findCell(id.value,column,true,strict);
if (z.length){
if (self._h2)
self.openItem(z[0][0]);
self.selectCell(self.getRowIndex(z[0][0]),(column||0))
}
},500);
};
}
if (id.parentNode)
id.parentNode.className+=" filter";
}
dhtmlXGridObject.prototype._loadSelectOptins=function(t,c){
var l=this.collectValues(c);
var v=t.value;
t.innerHTML="";
t.options[0]=new Option("","");
var f=this._filter_tr?this._filter_tr[c]:null;
for (var i=0; i<l.length; i++)
t.options[t.options.length]=new Option(f?f(l[i]):l[i],l[i]);
t.value=v;
}
dhtmlXGridObject.prototype.setSelectFilterLabel=function(ind,fun){
if (!this._filter_tr) this._filter_tr=[];
this._filter_tr[ind]=fun;
}
dhtmlXGridObject.prototype._loadComboOptins=function(t,c){
if (!t.combo) return; // prevent calls from refreshFilters
var l=this.collectValues(c);
t.combo.clearAll();
var opts = [["",""]];
for (var i=0; i<l.length; i++) opts.push([l[i],l[i]]);
t.combo.addOption(opts);
}
/**
* @desc: refresh filtering ( can be used if data in grid changed and filters need to be updated )
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.refreshFilters=function(){
if(!this.filters) return;
for (var i=0; i<this.filters.length; i++){
switch(this.filters[i][0].tagName.toLowerCase()){
case "input":
break;
case "select":
this._loadSelectOptins.apply(this,this.filters[i]);
break;
case "div":
this._loadComboOptins.apply(this,this.filters[i]);
break;
}
}
}
dhtmlXGridObject.prototype._filters_ready=function(fl,code){
this.attachEvent("onXLE",this.refreshFilters);
this.attachEvent("onRowCreated",function(id,r){
if (this._f_rowsBuffer)
for (var i=0; i<this._f_rowsBuffer.length; i++)
if (this._f_rowsBuffer[i].idd == id)
return this._f_rowsBuffer[i]=r;
})
this.attachEvent("onClearAll",function(){
this._f_rowsBuffer=null;
if (!this.hdr.rows.length)
this.filters=[];
});
/*
if (window.dhtmlXCombo)
this.attachEvent("onScroll",dhtmlXCombo.prototype.closeAll);
*/
this.attachEvent("onSetSizes", this._filters_resize_combo);
this.attachEvent("onResize", this._filters_resize_combo);
this._filters_ready=function(){};
}
dhtmlXGridObject.prototype._filters_resize_combo=function(){
if (!this.filters) return;
for (var q=0; q<this.filters.length; q++) {
if (this.filters[q][0].combo != null) {
this.filters[q][0].combo.setSize(Math.round(this.filters[q][0].offsetWidth*90/100));
}
}
return true;
}
dhtmlXGridObject.prototype._in_header_text_filter=function(t,i){
t.innerHTML="<input type='text'>";
t.onclick=t.onmousedown = function(e){ (e||event).cancelBubble=true; return true; }
t.onselectstart=function(){ return (event.cancelBubble=true); }
this.makeFilter(t.firstChild,i);
}
dhtmlXGridObject.prototype._in_header_text_filter_inc=function(t,i){
t.innerHTML="<input type='text'>";
t.onclick=t.onmousedown = function(e){ (e||event).cancelBubble=true; return true; }
t.onselectstart=function(){ return (event.cancelBubble=true); }
this.makeFilter(t.firstChild,i);
t.firstChild._filter=function(){
if (t.firstChild.value=="") return "";
return function(val){
return (val.toString().toLowerCase().indexOf(t.firstChild.value.toLowerCase())==0);
}
}
this._filters_ready();
}
dhtmlXGridObject.prototype._in_header_select_filter=function(t,i){
t.innerHTML="<select></select>";
t.onclick=function(e){ (e||event).cancelBubble=true; return false; }
this.makeFilter(t.firstChild,i);
}
dhtmlXGridObject.prototype._in_header_select_filter_strict=function(t,i){
t.innerHTML="<select style='width:90%; font-size:8pt; font-family:Tahoma;'></select>";
t.onclick=function(e){ (e||event).cancelBubble=true; return false; }
this.makeFilter(t.firstChild,i);
var combos = this.combos;
t.firstChild._filter=function(){
var value = t.firstChild.value;
if (!value) return "";
if (combos[i])
value = combos[i].keys[combos[i].values._dhx_find(value)];
value = value.toLowerCase();
return function(val){
return (val.toString().toLowerCase()==value);
};
};
this._filters_ready();
}
dhtmlXGridObject.prototype._in_header_combo_filter=function(t,i){
t.innerHTML="<div style='width:100%; padding-left:2px; overflow:hidden; ' class='combo'></div>";
t.onselectstart=function(){ return (event.cancelBubble=true); }
t.onclick=t.onmousedown=function(e){ (e||event).cancelBubble=true; return true; }
this.makeFilter(t.firstChild,i);
}
dhtmlXGridObject.prototype._search_common=function(t, i){
t.innerHTML="<input type='text' style='width:90%; '>";
t.onclick= t.onmousedown = function(e){ (e||event).cancelBubble=true; return true; }
t.onselectstart=function(){ return (event.cancelBubble=true); }
}
dhtmlXGridObject.prototype._in_header_text_search=function(t,i, strict){
this._search_common(t, i);
this.makeSearch(t.firstChild,i);
}
dhtmlXGridObject.prototype._in_header_text_search_strict=function(t,i){
this._search_common(t, i);
this.makeSearch(t.firstChild,i, true);
}
dhtmlXGridObject.prototype._in_header_numeric_filter=function(t,i){
this._in_header_text_filter.call(this,t,i);
t.firstChild._filter=function(){
var v=this.value;
var r; var op="=="; var num=parseFloat(v.replace("=","")); var num2=null;
if (v){
if (v.indexOf("..")!=-1){
v=v.split("..");
num=parseFloat(v[0]);
num2=parseFloat(v[1]);
return function(v){
if (v>=num && v<=num2) return true;
return false;
}
}
r=v.match(/>=|<=|>|</)
if (r) {
op=r[0];
num=parseFloat(v.replace(op,""));
}
return Function("v"," if (v "+op+" "+num+" ) return true; return false;");
}
return "";
};
}
dhtmlXGridObject.prototype._in_header_master_checkbox=function(t,i,c){
t.innerHTML=c[0]+"<input type='checkbox' />"+c[1];
var self=this;
t.getElementsByTagName("input")[0].onclick=function(e){
self._build_m_order();
var j=self._m_order?self._m_order[i]:i;
var val=this.checked?1:0;
self.forEachRowA(function(id){
var c=this.cells(id,j);
if (c.isCheckbox()) {
c.setValue(val);
c.cell.wasChanged = true;
}
this.callEvent("onEditCell",[1,id,j,val]);
this.callEvent("onCheckbox", [id, j, val]);
});
(e||event).cancelBubble=true;
}
}
dhtmlXGridObject.prototype._in_header_stat_total=function(t,i,c){
var calck=function(){
var summ=0;
this._build_m_order();
var ii = this._m_order?this._m_order[i]:i;
for (var j=0; j<this.rowsBuffer.length; j++){
var v=parseFloat(this._get_cell_value(this.rowsBuffer[j],ii));
summ+=isNaN(v)?0:v;
}
return this._maskArr[ii]?this._aplNF(summ,ii):(Math.round(summ*100)/100);
}
this._stat_in_header(t,calck,i,c,c);
}
dhtmlXGridObject.prototype._in_header_stat_multi_total=function(t,i,c){
var cols=c[1].split(":"); c[1]="";
for(var k = 0; k < cols.length;k++){
cols[k]=parseInt(cols[k]);
}
var calck=function(){
var summ=0;
for (var j=0; j<this.rowsBuffer.length; j++){
var v = 1;
for(var k = 0; k < cols.length;k++){
v *= parseFloat(this._get_cell_value(this.rowsBuffer[j],cols[k]))
}
summ+=isNaN(v)?0:v;
}
return this._maskArr[i]?this._aplNF(summ,i):(Math.round(summ*100)/100);
}
var track=[];
for(var ind = 0; ind < cols.length;ind++){
track[cols[ind]]=true;
}
this._stat_in_header(t,calck,track,c,c);
}
dhtmlXGridObject.prototype._in_header_stat_max=function(t,i,c){
var calck=function(){
this._build_m_order();
var ii = this._m_order?this._m_order[i]:i;
var summ=-999999999;
if (this.getRowsNum()==0) return "&nbsp;";
for (var j=0; j<this.rowsBuffer.length; j++)
summ=Math.max(summ,parseFloat(this._get_cell_value(this.rowsBuffer[j],ii)));
return this._maskArr[i]?this._aplNF(summ,i):summ;
}
this._stat_in_header(t,calck,i,c);
}
dhtmlXGridObject.prototype._in_header_stat_min=function(t,i,c){
var calck=function(){
this._build_m_order();
var ii = this._m_order?this._m_order[i]:i;
var summ=999999999;
if (this.getRowsNum()==0) return "&nbsp;";
for (var j=0; j<this.rowsBuffer.length; j++)
summ=Math.min(summ,parseFloat(this._get_cell_value(this.rowsBuffer[j],ii)));
return this._maskArr[i]?this._aplNF(summ,i):summ;
}
this._stat_in_header(t,calck,i,c);
}
dhtmlXGridObject.prototype._in_header_stat_average=function(t,i,c){
var calck=function(){
this._build_m_order();
var ii = this._m_order?this._m_order[i]:i;
var summ=0; var count=0;
if (this.getRowsNum()==0) return "&nbsp;";
for (var j=0; j<this.rowsBuffer.length; j++){
var v=parseFloat(this._get_cell_value(this.rowsBuffer[j],ii));
summ+=isNaN(v)?0:v;
count++;
}
return this._maskArr[i]?this._aplNF(summ/count,i):(Math.round(summ/count*100)/100);
}
this._stat_in_header(t,calck,i,c);
}
dhtmlXGridObject.prototype._in_header_stat_count=function(t,i,c){
var calck=function(){
return this.getRowsNum();
}
this._stat_in_header(t,calck,i,c);
}
dhtmlXGridObject.prototype._stat_in_header=function(t,calck,i,c){
var that=this;
var f=function(){
this.dma(true)
t.innerHTML=(c[0]?c[0]:"")+calck.call(this)+(c[1]?c[1]:"");
this.dma(false)
this.callEvent("onStatReady",[])
}
if (!this._stat_events) {
this._stat_events=[];
this.attachEvent("onClearAll",function(){
if (!this.hdr.rows[1]){
for (var i=0; i<this._stat_events.length; i++)
for (var j=0; j < 4; j++)
this.detachEvent(this._stat_events[i][j]);
this._stat_events=[];
}
})
}
this._stat_events.push([
this.attachEvent("onGridReconstructed",f),
this.attachEvent("onXLE",f),
this.attachEvent("onFilterEnd",f),
this.attachEvent("onEditCell",function(stage,id,ind){
if (stage==2 && ( ind==i || ( i && i[ind]) ) ) f.call(this);
return true;
})]);
t.innerHTML="";
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,123 @@
/*
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
*/
dhtmlXGridObject.prototype._in_header_number_filter=function(t,i){
this._in_header_text_filter.call(this,t,i);
var self = this;
t.firstChild._filter=function(){
var filters = self._get_filters(this.value, 'num');
return function(value) {
var result = filters.length > 0 ? false : true;
for (var i = 0; i < filters.length; i++)
result = result || filters[i](value);
return result;
}
};
}
dhtmlXGridObject.prototype._in_header_string_filter=function(t,i){
this._in_header_text_filter.call(this,t,i);
var self = this;
t.firstChild._filter=function(){
var filters = self._get_filters(this.value, 'str');
return function(value) {
var result = filters.length > 0 ? false : true;
for (var i = 0; i < filters.length; i++)
result = result || filters[i](value);
return result;
}
};
}
dhtmlXGridObject.prototype._get_filters=function(value, type) {
var fs = value.split(',');
var filters = [];
for (var i = 0; i < fs.length; i++) {
if (fs[i] == '') continue;
var f = this['_get_' + type + '_filter'](fs[i]);
filters.push(f);
}
return filters;
}
dhtmlXGridObject.prototype._get_str_filter=function(value) {
// empty, null
if (value == 'null' || value == 'empty') {
return new Function('value', 'if (value == null || value == "") return true; return false;');
}
// not empty, not null
if (value == '!null' || value == '!empty') {
return new Function('value', 'if (value == null || value == "") return false; return true;');
}
// not equals
if (value.substr(0, 1) === '!') {
var substr = value.substr(1);
return new Function('value', 'if (value !== "' + substr + '") return true; return false;');
}
// contains
if (value.substr(0, 1) === '~') {
var substr = value.substr(1);
return new Function('value', 'if (value.indexOf("' + substr + '") !== -1) return true; return false;');
}
// ^keyword&
if (value.substr(0, 1) === '^' && value.substr(value.length - 1, 1) === '&') {
value = '=' + value.substr(1, value.length - 2);
}
// start with
if (value.substr(0, 1) === '^') {
var substr = value.substr(1);
return new Function('value', 'if (value.substr(0, ' + substr.length + ') === "' + substr + '") return true; return false;');
}
// end with
if (value.substr(value.length - 1, 1) === '&') {
var substr = value.substr(0, value.length - 1);
return new Function('value', 'if (value.substr(value.length - ' + substr.length + ') === "' + substr + '") return true; return false;');
}
// equals
if (value.substr(0, 1) === '=')
var substr = value.substr(1);
else
var substr = value;
return new Function('value', 'if (value === "' + substr + '") return true; return false;');
}
dhtmlXGridObject.prototype._get_num_filter=function(value) {
// empty, null
if (value == 'null' || value == 'empty') {
return new Function('value', 'if (value == null || value == "") return true; return false;');
}
// not empty, not null
if (value == '!null' || value == '!empty') {
return new Function('value', 'if (value == null || value == "") return false; return true;');
}
// in range
var range = value.split('..');
if (range.length == 2) {
var num1 = parseFloat(range[0]);
var num2 = parseFloat(range[1]);
return new Function('value', 'if (value >= ' + num1 + ' && value <= ' + num2 + ') return true; return false;');
}
var r = value.match(/<>|>=|<=|>|<|=/);
if (r) {
var op = r[0];
var num = parseFloat(value.replace(op, ""));
} else {
var op = '==';
num = parseFloat(value);
}
if (op == '<>') op = '!=';
if (op == '=') op = '==';
return new Function("value"," if (value " + op + " " + num + " ) return true; return false;");
}

View File

@ -0,0 +1,212 @@
/*
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
*/
dhtmlXGridObject.prototype.attachHeaderA=dhtmlXGridObject.prototype.attachHeader;
dhtmlXGridObject.prototype.attachHeader=function()
{
this.attachHeaderA.apply(this,arguments);
if (this._realfake) return true;
this.formAutoSubmit();
if (typeof(this.FormSubmitOnlyChanged)=="undefined")
this.submitOnlyChanged(true);
if (typeof(this._submitAR)=="undefined")
this.submitAddedRows(true);
var that=this;
this._added_rows=[];
this._deleted_rows=[];
this.attachEvent("onRowAdded",function(id){
that._added_rows.push(id);
that.forEachCell(id,function(a){ a.cell.wasChanged=true; })
return true;
});
this.attachEvent("onBeforeRowDeleted",function(id){
that._deleted_rows.push(id);
return true;
});
this.attachHeader=this.attachHeaderA;
}
dhtmlXGridObject.prototype.formAutoSubmit = function()
{
this.parentForm = this.detectParentFormPresent();
if (this.parentForm === false) {
return false;
}
if (this.formEventAttached)
return;
this.formInputs = new Array();
var self = this;
dhtmlxEvent(this.parentForm, 'submit', function() {if (self.entBox) self.parentFormOnSubmit();});
this.formEventAttached = true;
}
dhtmlXGridObject.prototype.parentFormOnSubmit = function()
{
this.formCreateInputCollection();
if (!this.callEvent("onBeforeFormSubmit",[])) return false;
}
/**
* @desc: include only changed rows in form submit
* @type: public
* @param: mode - {boolean} enable|disable mode
* @topic: 0
*/
dhtmlXGridObject.prototype.submitOnlyChanged = function(mode)
{
this.FormSubmitOnlyChanged = convertStringToBoolean(mode);
}
dhtmlXGridObject.prototype.submitColumns=function(names){
if (typeof names == "string") names=names.split(this.delim);
this._submit_cols=names;
}
/**
* @desc: allows to define input name which will be used for data sending, name may contain next auto-replaced elements - GRID_ID - ID of grids container, ROW_ID - ID of row, ROW_INDEX - index of row, COLUMN_ID - id of column, COLUMN_INDEX - index of column
* @type: public
* @param: name - input name mask
* @topic: 0
*/
dhtmlXGridObject.prototype.setFieldName=function(mask){
mask=mask.replace(/\{GRID_ID\}/g,"'+a1+'");
mask=mask.replace(/\{ROW_ID\}/g,"'+a2+'");
mask=mask.replace(/\{ROW_INDEX\}/g,"'+this.getRowIndex(a2)+'");
mask=mask.replace(/\{COLUMN_INDEX\}/g,"'+a3+'");
mask=mask.replace(/\{COLUMN_ID\}/g,"'+this.getColumnId(a3)+'");
this._input_mask=Function("a1","a2","a3","return '"+mask+"';");
}
/**
* @desc: include serialized grid as part of form submit
* @type: public
* @param: mode - {boolean} enable|disable mode
* @topic: 0
*/
dhtmlXGridObject.prototype.submitSerialization = function(mode)
{
this.FormSubmitSerialization = convertStringToBoolean(mode);
}
/**
* @desc: include additional data with info about which rows was added and which deleted, enabled by default
* @type: public
* @param: mode - {boolean} enable|disable mode
* @topic: 0
*/
dhtmlXGridObject.prototype.submitAddedRows = function(mode)
{
this._submitAR = convertStringToBoolean(mode);
}
/**
* @desc: include only selected rows in form submit
* @type: public
* @param: mode - {boolean} enable|disable mode
* @topic: 0
*/
dhtmlXGridObject.prototype.submitOnlySelected = function(mode)
{
this.FormSubmitOnlySelected = convertStringToBoolean(mode);
}
/**
* @desc: include only row's IDS in form submit
* @type: public
* @param: mode - {boolean} enable|disable mode
* @topic: 0
*/
dhtmlXGridObject.prototype.submitOnlyRowID = function(mode)
{
this.FormSubmitOnlyRowID = convertStringToBoolean(mode);
}
dhtmlXGridObject.prototype.createFormInput = function(name,value){
var input = document.createElement('input');
input.type = 'hidden';
if (this._input_mask && (typeof name != "string"))
input.name=this._input_mask.apply(this,name);
else
input.name =((this.globalBox||this.entBox).id||'dhtmlXGrid')+'_'+name;
input.value = value;
this.parentForm.appendChild(input);
this.formInputs.push(input);
}
dhtmlXGridObject.prototype.createFormInputRow = function(r){
var id=(this.globalBox||this.entBox).id;
for (var j=0; j<this._cCount; j++){
var foo_cell = this.cells3(r, j);
if (((!this.FormSubmitOnlyChanged) || foo_cell.wasChanged()) && (!this._submit_cols || this._submit_cols[j]))
this.createFormInput(this._input_mask?[id,r.idd,j]:(r.idd+'_'+j),foo_cell.getValue());
}
}
dhtmlXGridObject.prototype.formCreateInputCollection = function()
{
if (this.parentForm == false) {
return false;
}
for (var i=0; i<this.formInputs.length; i++) {
this.parentForm.removeChild(this.formInputs[i]);
}
this.formInputs = new Array();
if (this.FormSubmitSerialization){
this.createFormInput("serialized",this.serialize());
} else if (this.FormSubmitOnlySelected){
//submit selected
if (this.FormSubmitOnlyRowID)
this.createFormInput("selected",this.getSelectedId());
else
for(var i=0;i<this.selectedRows.length;i++)
this.createFormInputRow(this.selectedRows[i]);
}
else{
//submit all
if (this._submitAR){
if (this._added_rows.length)
this.createFormInput("rowsadded",this._added_rows.join(","));
if (this._deleted_rows.length)
this.createFormInput("rowsdeleted",this._deleted_rows.join(","));
}
this.forEachRow(function(id){
this.getRowById(id);
this.createFormInputRow(this.rowsAr[id]);
})
}
}
dhtmlXGridObject.prototype.detectParentFormPresent = function()
{
var parentForm = false;
var parent = this.entBox;
while(parent && parent.tagName && parent != document.body) {
if (parent.tagName.toLowerCase() == 'form') {
parentForm = parent;
break;
} else {
parent = parent.parentNode;
}
}
return parentForm;
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,536 @@
/*
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
*/
dhtmlXGridObject.prototype.unGroup=function(){
if (!this._groups) return;
this._dndProblematic=false;
delete this._groups;
delete this._gIndex;
if (this._fake) this._mirror_rowsCol();
this.forEachRow(function(id){
this.rowsAr[id].style.display='';
})
this._reset_view();
this.callEvent("onGridReconstructed",[])
this.callEvent("onUnGroup",[]);
}
dhtmlXGridObject.prototype._mirror_rowsCol=function(){
this._fake._groups=this._groups;
this._fake._gIndex=this._gIndex;
this.rowsBuffer=dhtmlxArray();
for (var i=0; i<this.rowsCol.length; i++)
if (!this.rowsCol[i]._cntr)
this.rowsBuffer.push(this.rowsCol[i]);
this._fake.rowsBuffer=dhtmlxArray();
for (var i=0; i<this._fake.rowsCol.length; i++)
if (!this._fake.rowsCol[i]._cntr)
this._fake.rowsBuffer.push(this._fake.rowsCol[i]);
}
/**
* @desc: group grid content by values of specified column
* @param: ind - column index to group by
* @edition: Professional
* @type: public
*/
dhtmlXGridObject.prototype.groupBy=function(ind,mask){
if (this._groups) this.unGroup();
this._dndProblematic=true;
this._groups={};
if (!mask) {
mask=["#title"];
for (var i=1; i<this._cCount; i++) mask.push("#cspan");
}
this._gmask=document.createElement("TR");
this._gmask.origin = mask;
var ltd,rindex=0;
for (var i=0; i<mask.length; i++){
if (mask[i]=="#cspan")
ltd.colSpan=(parseInt(ltd.colSpan)||1)+1
else {
ltd=document.createElement("TD");
ltd._cellIndex=i;
if (this._hrrar[i]) ltd.style.display="none";
ltd.className="group_row";
ltd.innerHTML="&nbsp;";
if (mask[i]=="#title") this._gmask._title=rindex;
else ltd.align=this.cellAlign[i]||"left";
this._gmask.appendChild(ltd);
if (mask[i].indexOf("#stat")==0){
this._gmask._math=true;
ltd._counter=[this["_g_"+mask[i].replace("#","")],i,rindex];
}
rindex++;
}
}
for (var a in this._groups) this._groups[a]=this.undefined;
this._gIndex=ind;
if (this._fake &&!this._realfake){
this._fake._groups=[];
this._fake._gIndex=this._gIndex;
}
//keyboard commands
this._nextRow=function(ind,dir){
var r=this.rowsCol[ind+dir];
if (r && ( r.style.display=="none" || r._cntr)) return this._nextRow(ind+dir,dir);
return r;
}
if (!this.__sortRowsBG){
this._key_events=dhtmlXHeir({},this._key_events)
this._key_events.k38_0_0=function(){
if (this.editor && this.editor.combo)
this.editor.shiftPrev();
else{
var rowInd = this.row.rowIndex;
if (!rowInd) return;
var nrow=this._nextRow(rowInd-1,-1);
if (nrow)
this.selectCell(nrow,this.cell._cellIndex,true);
}
}
this._key_events.k13_1_0=this._key_events.k13_0_1=function(){};
this._key_events.k40_0_0=function(){
if (this.editor && this.editor.combo)
this.editor.shiftNext();
else{
var rowInd = this.row.rowIndex;
if (!rowInd) return;
var nrow=this._nextRow(rowInd-1,1);
if (nrow)
this.selectCell(nrow,this.cell._cellIndex,true);
}
}
this.attachEvent("onFilterStart",function(){
if (this._groups) this._groups=this.undefined;
return true;
});
this.attachEvent("onFilterEnd",function(){
if (typeof this._gIndex != "undefined") this.groupBy(this._gIndex,this._gmask.origin);
});
this.sortRows_bg=this.sortRows;
this.sortRows=function(ind,type,dir){
if (typeof(this._groups)=="undefined") return this.sortRows_bg.apply(this,arguments);
this.callEvent("onBeforeSorting",[ind,(type||"str"),(dir||"asc")]);
}
this.attachEvent("onBeforeSorting",function(ind,type,dir){
if (typeof(this._groups)=="undefined") return true;
if (ind==this._gIndex) this._sortByGroup(ind,type,dir);
else this._sortInGroup(ind,type,dir);
this.setSortImgState(true,ind,dir)
if (this._fake){
this._mirror_rowsCol();
this._fake._groups=[];
this._fake._reset_view();
}
this.setSortImgState(true,ind,dir);
this.callEvent("onAfterSorting",[ind,type,dir]);
return false;
});
this.attachEvent("onClearAll",function(){ this.unGroup(); });
this.attachEvent("onBeforeRowDeleted",function(id){
if (!this._groups) return true;
if (!this.rowsAr[id]) return true;
var val=this.cells(id,this._gIndex).getValue();
if (val==="") val=" ";
var z=this._groups[val];
this._dec_group(z);
return true;
});
this.attachEvent("onAfterRowDeleted",function(id){
this.updateGroups();
});
this.attachEvent("onCheckbox",function(id,index,value){
this.callEvent("onEditCell",[2,id,index,(value?1:0),(value?0:1)]);
});
this.attachEvent("onXLE",this.updateGroups);
this.attachEvent("onColumnHidden",this.hideGroupColumn);
this.attachEvent("onEditCell",function(stage,id,ind,val,oldval){
if (!this._groups) return true;
if (stage==2 && val!=oldval && ind==this._gIndex){
if (oldval==="") oldval=" ";
this._dec_group(this._groups[oldval]);
var r=this.rowsAr[id];
var i=this.rowsCol._dhx_find(r)
var ni=this._inc_group(val);
var n=this.rowsCol[ni];
if (r==n) n=n.nextSibling;
var p=r.parentNode;
var o=r.rowIndex;
p.removeChild(r);
if (n)
p.insertBefore(r,n);
else
p.appendChild(r);
this.rowsCol._dhx_insertAt(ni,r);
if (ni<i) i++;
this.rowsCol._dhx_removeAt(i,r);
this._fixAlterCss();
} else if (stage==2 && val!=oldval) {
this.updateGroups();
this._updateGroupView(this._groups[this.cells(id,this._gIndex).getValue()||" "]);
}
return true;
})
this.__sortRowsBG=true;
}
this._groupExisting();
if (this._hrrar)
for (var i=0; i<this._hrrar.length; i++)
if (this._hrrar[i])
this.hideGroupColumn(i,true);
this.callEvent("onGroup",[]);
if (this._ahgr || this._awdth) this.setSizes();
}
dhtmlXGridObject.prototype._sortInGroup=function(col,type,order){
var b=this._groups_get();
b.reverse();
for (var i=0; i<b.length; i++){
var c=b[i]._cntr._childs; var a={};
for (var j=0; j<c.length; j++){
var cell = this.cells3(c[j],col);
a[c[j].idd]=cell.getDate?cell.getDate():cell.getValue();
}
this._sortCore(col,type,order,a,c);
}
//add|delete|edit|ungroup
this._groups_put(b);
this.setSizes();
this.callEvent("onGridReconstructed",[])
}
dhtmlXGridObject.prototype._sortByGroup=function(col,type,order){
var b=this._groups_get();
var a=[];
for (var i=0; i<b.length; i++){
b[i].idd="_sort_"+i;
a["_sort_"+i]=b[i]._cntr.text;
}
this._sortCore(col,type,order,a,b);
//add|delete|edit|ungroup
this._groups_put(b);
this.callEvent("onGridReconstructed",[])
this.setSizes();
}
dhtmlXGridObject.prototype._inc_group=function(val,hidden,skip){
if (val==="") val=" ";
if (!this._groups[val]){
this._groups[val]={text:val,row:this._addPseudoRow(),count:0,state:hidden?"plus":"minus"}; }
var z=this._groups[val];
//this._fixAlterCss();
z.row._cntr=z;
var ind=this.rowsCol._dhx_find(z.row)+z.count+1;
z.count++;
if (!skip) {
this._updateGroupView(z);
this.updateGroups();
}
return ind;
}
dhtmlXGridObject.prototype._dec_group=function(z){
if (!z) return;
z.count--;
if (z.count==0){
z.row.parentNode.removeChild(z.row);
this.rowsCol._dhx_removeAt(this.rowsCol._dhx_find(z.row));
delete this._groups[z.text];
}
else
this._updateGroupView(z);
if (this._fake && !this._realfake)
this._fake._dec_group(this._fake._groups[z.text]);
this.updateGroups();
return true;
}
dhtmlXGridObject.prototype._insertRowAt_gA=dhtmlXGridObject.prototype._insertRowAt;
dhtmlXGridObject.prototype._insertRowAt=function(r,ind,skip){
if (typeof(this._groups)!="undefined"){
if (this._realfake)
var val=this._fake._bfs_cells(r.idd,this._gIndex).getValue();
else
if (this._bfs_cells3)
var val=this._bfs_cells3(r,this._gIndex).getValue();
else
var val=this.cells3(r,this._gIndex).getValue();
if (!val) val=" ";
ind=this._inc_group(val,r.style.display=="none");
}
var res=this._insertRowAt_gA(r,ind,skip);
if (typeof(this._groups)!="undefined"){
this.expandGroup(val);
this._updateGroupView(this._groups[val]);
this.updateGroups();
}
return res;
}
dhtmlXGridObject.prototype._updateGroupView=function(z){
if (this._fake && !this._realfake) return z.row.firstChild.innerHTML="&nbsp;";
var mask = this._gmask||this._fake._gmask;
var html="<img style='margin-bottom:-4px' src='"+this.imgURL+z.state+".gif'> ";
if (this.customGroupFormat) html+=this.customGroupFormat(z.text,z.count);
else html+=z.text+" ( "+z.count+" ) ";
z.row.childNodes[mask._title].innerHTML=html;
}
dhtmlXGridObject.prototype._addPseudoRow=function(skip){
var mask = this._gmask||this._fake._gmask;
var r=mask.cloneNode(true)
//cloneNode ignores custom attributes
for (var i=0; i<r.childNodes.length; i++) {
r.childNodes[i]._cellIndex=mask.childNodes[i]._cellIndex;
if (this._realfake) r.childNodes[i].style.display="";
}
var that=this;
r.onclick=function(e){
if (!that.callEvent("onGroupClick",[this._cntr.text]))
return;
if (that._fake && that._realfake)
that._fake._switchGroupState(that._fake._groups[this._cntr.text].row);
else
that._switchGroupState(this);
(e||event).cancelBubble="true"; }
r.ondblclick=function(e){ (e||event).cancelBubble="true"; }
if (!skip){
if (_isKHTML)
this.obj.appendChild(r)
else
this.obj.firstChild.appendChild(r)
this.rowsCol.push(r);
}
return r;
}
dhtmlXGridObject.prototype._groups_get=function(){
var b=[];
this._temp_par=this.obj.parentNode;
this._temp_par.removeChild(this.obj);
var a=[];
for (var i=this.rowsCol.length-1; i>=0; i--){
if (this.rowsCol[i]._cntr){
this.rowsCol[i]._cntr._childs=a;
a=[];
b.push(this.rowsCol[i]);
} else a.push(this.rowsCol[i]);
this.rowsCol[i].parentNode.removeChild(this.rowsCol[i]);
}
return b;
}
dhtmlXGridObject.prototype._groups_put=function(b){
var sts = this.rowsCol.stablesort;
this.rowsCol=new dhtmlxArray(0);
this.rowsCol.stablesort = sts;
for (var i=0; i<b.length; i++){
var gr=b[i]._cntr;
this.obj.firstChild.appendChild(gr.row);
this.rowsCol.push(gr.row)
gr.row.idd=null;
for (var j=0; j<gr._childs.length; j++){
this.obj.firstChild.appendChild(gr._childs[j]);
this.rowsCol.push(gr._childs[j])
}
delete gr._childs;
}
this._temp_par.appendChild(this.obj);
}
dhtmlXGridObject.prototype._groupExisting=function(b){
if (!this.getRowsNum()) return;
var b=[];
this._temp_par=this.obj.parentNode;
this._temp_par.removeChild(this.obj);
var a=[];
var mlen=this.rowsCol.length;
for (var i=0; i<mlen; i++){
var val=this.cells4(this.rowsCol[i].childNodes[this._gIndex]).getValue();
this.rowsCol[i].style.display = "";
if (!val) val=" ";
if (!this._groups[val]){
this._groups[val]={text:val,row:this._addPseudoRow(true),count:0,state:"minus"};
var z=this._groups[val];
z.row._cntr=z;
this._groups[val]._childs=[];
b.push(z.row)
}
this._groups[val].count++;
this._groups[val]._childs.push(this.rowsCol[i]);
this.rowsCol[i].parentNode.removeChild(this.rowsCol[i]);
}
for (var i=0; i<b.length; i++)
this._updateGroupView(b[i]._cntr)
this._groups_put(b);
if (this._fake && !this._realfake) {
this._mirror_rowsCol();
this._fake._groups=[];
this._fake._reset_view();
}
this.callEvent("onGridReconstructed",[])
this.updateGroups();
}
dhtmlXGridObject.prototype._switchGroupState=function(row){
var z=row._cntr;
if (this._fake && !this._realfake) {
z.state=this._fake._groups[row._cntr.text].row._cntr.state;
this._fake._switchGroupState(this._fake._groups[row._cntr.text].row)
}
var ind=this.rowsCol._dhx_find(z.row)+1;
z.state=z.state=="minus"?"plus":"minus";
var st=z.state=="plus"?"none":"";
while(this.rowsCol[ind] && !this.rowsCol[ind]._cntr){
this.rowsCol[ind].style.display=st;
ind++;
}
this._updateGroupView(z);
this.callEvent("onGroupStateChanged",[z.text, (z.state=="minus")]);
this.setSizes();
}
/**
* @desc: expand group of rows
* @param: val - value to use to determine what group to expand (in other words this should be value common for all of them)
* @edition: Professional
* @type: public
*/
dhtmlXGridObject.prototype.expandGroup=function(val){
if (this._groups[val].state=="plus")
this._switchGroupState(this._groups[val].row);
}
/**
* @desc: collapse group of rows
* @param: val - value to use to determine what group to collapse (in other words this should be value common for all of them)
* @edition: Professional
* @type: public
*/
dhtmlXGridObject.prototype.collapseGroup=function(val){
if (this._groups[val].state=="minus")
this._switchGroupState(this._groups[val].row);
}
/**
* @desc: expand all groups
* @edition: Professional
* @type: public
*/
dhtmlXGridObject.prototype.expandAllGroups=function(){
for(var i in this._groups)
if (this._groups[i] && this._groups[i].state=="plus")
this._switchGroupState(this._groups[i].row);
}
/**
* @desc: collapse all groups
* @edition: Professional
* @type: public
*/
dhtmlXGridObject.prototype.collapseAllGroups=function(){
for(var i in this._groups)
if (this._groups[i] && this._groups[i].state=="minus")
this._switchGroupState(this._groups[i].row);
}
dhtmlXGridObject.prototype.hideGroupColumn=function(ind,state){
if (this._fake) return;
var rind=-1;
var row = this._gmask.childNodes;
for (var i=0; i<row.length; i++)
if (row[i]._cellIndex==ind) {
rind = i;
break;
}
if (rind == -1) return;
for (var a in this._groups)
this._groups[a].row.childNodes[rind].style.display=state?"none":"";
};
dhtmlXGridObject.prototype.groupStat=function(name,ind,math){
math = this["_g_"+(math||"stat_total")];
var summ=0; var index=0;
this.forEachRowInGroup(name,function(id){
summ=math(summ,this.cells(id,ind).getValue()*1,index)
index++;
})
return summ;
}
dhtmlXGridObject.prototype.forEachRowInGroup=function(name,code){
var row=this._groups[name].row.nextSibling;
if (row){
while (row && !row._cntr) {
code.call(this,row.idd);
row=row.nextSibling;
}
} else {
var cs=this._groups[name]._childs;
if (cs)
for (var i=0; i<cs.length; i++)
code.call(this,cs[i].idd);
}
};
dhtmlXGridObject.prototype.updateGroups=function(){
if (!this._gmask || !this._gmask._math || this._parsing) return;
var r=this._gmask.childNodes;
for (var i=0; i<r.length; i++)
if (r[i]._counter) this._b_processing.apply(this,r[i]._counter)
}
dhtmlXGridObject.prototype._b_processing=function(a,ind,rind){
var c=0,j=0;
//put editor in cache, so it can be used for custom html containers - can be moved in cells5(?)
if (!this._ecache[this.cellType[ind]]) this.cells5({parentNode:{grid:this}},this.cellType[ind]);
for (var i=this.rowsCol.length-1; i>=0; i--){
if (!this.rowsCol[i]._cntr){
c=a(c,this.cells3(this.rowsCol[i],ind).getValue()*1,j);
j++;
} else {
this.cells5(this.rowsCol[i].childNodes[rind],this.cellType[ind]).setValue(c);
j=c=0;
}
}
}
dhtmlXGridObject.prototype._g_stat_total=function(c,n,i){
return c+n;
}
dhtmlXGridObject.prototype._g_stat_min=function(c,n,i){
if (!i) c=Infinity;
return Math.min(c,n);
}
dhtmlXGridObject.prototype._g_stat_max=function(c,n,i){
if (!i) c=-Infinity;
return Math.max(c,n);
}
dhtmlXGridObject.prototype._g_stat_average=function(c,n,i){
return (c*i+n)/(i+1);
}
dhtmlXGridObject.prototype._g_stat_count=function(c,n,i){
return c++;
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,62 @@
/*
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
*/
dhtmlXGridObject.prototype._in_header_collapse=function(t,i,c){
var rt=t.tagName=="TD"?t:t.parentNode;
i=rt._cellIndexS;
if (!this._column_groups) this._column_groups=[];
var cols=c[1].split(":")
var cols=c[1].split(":");
cols = [cols.shift(), cols.join(':')];
var count = parseInt(cols[0]);
t.innerHTML=c[0]+"<img src='"+this.imgURL+"minus.gif' style='padding-right:10px;height:16px'/><span style='position:relative; top:-6px;'>"+(cols[1]||"")+"<span>";
t.style.paddingBottom='0px';
var self = this;
this._column_groups[i]=t.getElementsByTagName("IMG")[0];
this._column_groups[i].onclick=function(e){
(e||event).cancelBubble=true;
this._cstate=!this._cstate;
for (var j=i+1; j<(i+count); j++)
self.setColumnHidden(j,this._cstate)
if (this._cstate){
if (rt.colSpan && rt.colSpan>0) {
rt._exp_colspan=rt.colSpan;
var delta=Math.max(1,rt.colSpan-count)
if (!_isFF) //create additional cells to compensate colspan
for (var z=0; z<rt.colSpan-delta; z++){
var td=document.createElement("TD");
if (rt.nextSibling)
rt.parentNode.insertBefore(td,rt.nextSibling);
else
rt.parentNode.appendChild(td);
}
rt.colSpan=delta;
}
self.callEvent("onColumnCollapse",[i,this._cstate]);
} else
if (rt._exp_colspan){
rt.colSpan=rt._exp_colspan;
if (!_isFF)
for (var z=1; z<rt._exp_colspan; z++)
rt.parentNode.removeChild(rt.nextSibling);
self.callEvent("onColumnCollapse",[i,this._cstate]);
}
this.src=self.imgURL+(this._cstate?"plus.gif":"minus.gif");
if (self.sortImg.style.display!="none")
self.setSortImgPos();
}
}
dhtmlXGridObject.prototype.collapseColumns = function (ind) {
if (!this._column_groups[ind] || this._column_groups[ind]._cstate) return;
this._column_groups[ind].onclick({});
}
dhtmlXGridObject.prototype.expandColumns = function (ind) {
if (!this._column_groups[ind] || !this._column_groups[ind]._cstate) return;
this._column_groups[ind].onclick({});
}

View File

@ -0,0 +1,158 @@
/*
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: enable pop up menu which allows hidding/showing columns
* @edition: Professional
* @type: public
*/
dhtmlXGridObject.prototype.enableHeaderMenu=function(columns)
{
if (typeof columns == "string")
columns = columns.split(",");
this._hm_config = columns;
var that=this;
this.attachEvent("onInit",function(){
this.hdr.oncontextmenu = function(e){ return that._doHContClick(e||window.event); };
{
this.startColResizeA=this.startColResize;
this.startColResize=function(e){
if (e.button==2 || (_isMacOS&&e.ctrlKey))
return this._doHContClick(e)
return this.startColResizeA(e);
}
}
this._chm_ooc=this.obj.onclick;
this._chm_hoc=this.hdr.onclick;
this.hdr.onclick=function(e){
if (e && ( e.button==2 || (_isMacOS&&e.ctrlKey))) return false;
that._showHContext(false);
return that._chm_hoc.apply(this,arguments)
}
this.obj.onclick=function(){
that._showHContext(false);
return that._chm_ooc.apply(this,arguments)
}
});
dhtmlxEvent(document.body,"click",function(){
if (that._hContext)
that._showHContext(false);
})
if (this.hdr.rows.length) this.callEvent("onInit",[]);
this.enableHeaderMenu=function(){};
}
dhtmlXGridObject.prototype._doHContClick=function(ev)
{
function mouseCoords(ev){
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
var d = ((_isIE)&&(document.compatMode != "BackCompat"))?document.documentElement:document.body;
return {
x:ev.clientX + d.scrollLeft - d.clientLeft,
y:ev.clientY + d.scrollTop - d.clientTop
};
}
this._createHContext();
var coords = mouseCoords(ev);
this._showHContext(true,coords.x,coords.y);
ev[_isIE?"srcElement":"target"].oncontextmenu = function(e){ (e||event).cancelBubble=true; return false; };
ev.cancelBubble=true;
if (ev.preventDefault) ev.preventDefault();
return false;
}
dhtmlXGridObject.prototype._createHContext=function()
{
if (this._hContext) return this._hContext;
var d = document.createElement("DIV");
d.oncontextmenu = function(e){ (e||event).cancelBubble=true; return false; };
d.onclick=function(e){
(e||event).cancelBubble=true;
return true;
}
d.className="dhx_header_cmenu";
d.style.width=d.style.height="5px";
d.style.display="none";
var a=[];
var i=0;
if (this._fake)
i=this._fake._cCount;
var true_ind=i;
for (var i; i<this.hdr.rows[1].cells.length; i++){
var c=this.hdr.rows[1].cells[i];
if (!this._hm_config || (this._hm_config[i] && this._hm_config[i] != "false")){
if (c.firstChild && c.firstChild.tagName=="DIV") var val=c.firstChild.innerHTML;
else var val = c.innerHTML;
val = val.replace(/<[^>]*>/gi,"");
a.push("<div class='dhx_header_cmenu_item'><input type='checkbox' column='"+true_ind+"' len='"+(c.colSpan||1)+"' checked='true' />"+val+"</div>");
}
true_ind+=(c.colSpan||1);
}
d.innerHTML=a.join("");
var that=this;
var f=function(){
var c=this.getAttribute("column");
if (!this.checked && !that._checkLast(c)) return this.checked=true;
if (that._realfake) that=that._fake;
for (var i=0; i<this.getAttribute("len"); i++)
that.setColumnHidden((c*1+i*1),!this.checked);
if(this.checked && that.getColWidth(c)==0)
that.adjustColumnSize(c);
}
for (var i=0; i<d.childNodes.length; i++)
d.childNodes[i].firstChild.onclick=f;
document.body.insertBefore(d,document.body.firstChild);
this._hContext=d;
d.style.position="absolute";
d.style.zIndex=999;
d.style.width='auto'
d.style.height='auto'
d.style.display='block';
}
dhtmlXGridObject.prototype._checkLast=function(ind){
for (var i=0; i < this._cCount; i++)
if ((!this._hrrar || !this._hrrar[i])&&(i!=ind))
return true;
return false;
}
dhtmlXGridObject.prototype._updateHContext=function()
{
for (var i=0; i<this._hContext.childNodes.length; i++){
var c=this._hContext.childNodes[i].firstChild;
var col=c.getAttribute("column");
if (this.isColumnHidden(col) || (this.getColWidth(col)==0))
c.checked=false;
}
}
dhtmlXGridObject.prototype._showHContext=function(mode,x,y)
{
if (mode && this.enableColumnMove) {
this._hContext.parentNode.removeChild(this._hContext);
this._hContext=null;
}
this._createHContext();
this._hContext.style.display=(mode?'block':'none');
if (mode){
this._updateHContext(true);
this._hContext.style.left=x+"px";
this._hContext.style.top=y+"px";
}
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,342 @@
/*
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
*/
dhtmlXGridObject.prototype._process_json_row=function(r, data){
r._attrs=data;
for (var j = 0; j < r.childNodes.length; j++)r.childNodes[j]._attrs={
};
if (data.userdata)
for (var a in data.userdata)
this.setUserData(r.idd,a,data.userdata[a]);
data = this._c_order?this._swapColumns(data.data):data.data;
for (var i=0; i<data.length; i++)
if (typeof data[i] == "object" && data[i] != null){
r.childNodes[i]._attrs=data[i];
if (data[i].type) r.childNodes[i]._cellType=data[i].type;
data[i]=data[i].value;
}
this._fillRow(r, data);
return r;
};
dhtmlXGridObject.prototype._process_js_row=function(r, data){
r._attrs=data;
for (var j = 0; j < r.childNodes.length; j++)
r.childNodes[j]._attrs={};
if (data.userdata)
for (var a in data.userdata)
this.setUserData(r.idd,a,data.userdata[a]);
var arr = [];
for (var i=0; i<this.columnIds.length; i++){
arr[i] = data[this.columnIds[i]];
if (typeof arr[i] == "object" && arr[i] != null){
r.childNodes[i]._attrs=arr[i];
if (arr[i].type) r.childNodes[i]._cellType=arr[i].type;
arr[i]=arr[i].value;
}
if (!arr[i] && arr[i]!==0)
arr[i]="";
}
this._fillRow(r, arr);
return r;
};
dhtmlXGridObject.prototype.updateFromJSON = function(url, insert_new, del_missed, afterCall){
if (typeof insert_new == "undefined")
insert_new=true;
this._refresh_mode=[
true,
insert_new,
del_missed
];
this.load(url,afterCall,"json");
},
dhtmlXGridObject.prototype._refreshFromJSON = function(data){
if (this._f_rowsBuffer) this.filterBy(0,"");
reset = false;
if (window.eXcell_tree){
eXcell_tree.prototype.setValueX=eXcell_tree.prototype.setValue;
eXcell_tree.prototype.setValue=function(content){
var r=this.grid._h2.get[this.cell.parentNode.idd]
if (r && this.cell.parentNode.valTag){
this.setLabel(content);
} else
this.setValueX(content);
};
}
var tree = this.cellType._dhx_find("tree");
var pid = data.parent||0;
var del = {
};
if (this._refresh_mode[2]){
if (tree != -1)
this._h2.forEachChild(pid, function(obj){
del[obj.id]=true;
}, this);
else
this.forEachRow(function(id){
del[id]=true;
});
}
var rows = data.rows;
for (var i = 0; i < rows.length; i++){
var row = rows[i];
var id = row.id;
del[id]=false;
if (this.rowsAr[id] && this.rowsAr[id].tagName!="TR"){
if (this._h2)
this._h2.get[id].buff.data=row;
else
this.rowsBuffer[this.getRowIndex(id)].data=row;
this.rowsAr[id]=row;
} else if (this.rowsAr[id]){
this._process_json_row(this.rowsAr[id], row, -1);
this._postRowProcessing(this.rowsAr[id],true)
} else if (this._refresh_mode[1]){
var dadd={
idd: id,
data: row,
_parser: this._process_json_row,
_locator: this._get_json_data
};
var render_index = this.rowsBuffer.length;
if (this._refresh_mode[1]=="top"){
this.rowsBuffer.unshift(dadd);
render_index = 0;
} else
this.rowsBuffer.push(dadd);
if (this._h2){
reset=true;
(this._h2.add(id,pid)).buff=this.rowsBuffer[this.rowsBuffer.length-1];
}
this.rowsAr[id]=row;
row=this.render_row(render_index);
this._insertRowAt(row,render_index?-1:0)
}
}
if (this._refresh_mode[2])
for (id in del){
if (del[id]&&this.rowsAr[id])
this.deleteRow(id);
}
this._refresh_mode=null;
if (window.eXcell_tree)
eXcell_tree.prototype.setValue=eXcell_tree.prototype.setValueX;
if (reset) this._renderSort();
if (this._f_rowsBuffer) {
this._f_rowsBuffer = null;
this.filterByAll();
}
},
dhtmlXGridObject.prototype._process_js=function(data){
return this._process_json(data, "js");
},
dhtmlXGridObject.prototype._process_json=function(data, mode){
this._parsing=true;
try {
if (data&&data.xmlDoc){
eval("dhtmlx.temp="+data.xmlDoc.responseText+";");
data = dhtmlx.temp;
} else if (typeof data == "string"){
eval("dhtmlx.temp="+data+";");
data = dhtmlx.temp;
}
} catch(e){
dhtmlxError.throwError("LoadXML", "Incorrect JSON", [
(data.xmlDoc||data),
this
]);
data = {rows:[]};
}
if (this._refresh_mode) return this._refreshFromJSON(data);
var cr = parseInt(data.pos||0);
var total = parseInt(data.total_count||0);
var reset = false;
if (total){
if (!this.rowsBuffer[total-1]){
if (this.rowsBuffer.length)
reset=true;
this.rowsBuffer[total-1]=null;
}
if (total<this.rowsBuffer.length){
this.rowsBuffer.splice(total, this.rowsBuffer.length - total);
reset = true;
}
}
for (var key in data){
if (key!="rows")
this.setUserData("",key, data[key]);
}
if (mode == "js" && data.collections){
for (var colkey in data.collections){
var index = this.getColIndexById(colkey);
var colrecs = data.collections[colkey];
if (index !== window.undefined){
if (this.cellType[index] == "clist"){
colplaindata=[];
for (var j=0; j<colrecs.length; j++)
colplaindata.push(colrecs[j].label);
this.registerCList(index, colplaindata);
} else {
var combo = this.getCombo(index);
for (var j = 0; j < colrecs.length; j++)
combo.put(colrecs[j].value, colrecs[j].label);
}
}
}
}
if (this.isTreeGrid())
return this._process_tree_json(data, null, null, mode);
if (mode == "js"){
if (data.data)
data = data.data;
for (var i = 0; i < data.length; i++){
if (this.rowsBuffer[i+cr])
continue;
var row = data[i];
var id = row.id||(i+1);
this.rowsBuffer[i+cr]={
idd: id,
data: row,
_parser: this._process_js_row,
_locator: this._get_js_data
};
this.rowsAr[id]=data[i];
}
} else {
for (var i = 0; i < data.rows.length; i++){
if (this.rowsBuffer[i+cr])
continue;
var id = data.rows[i].id;
this.rowsBuffer[i+cr]={
idd: id,
data: data.rows[i],
_parser: this._process_json_row,
_locator: this._get_json_data
};
this.rowsAr[id]=data.rows[i];
}
}
if (reset && this._srnd){
var h = this.objBox.scrollTop;
this._reset_view();
this.objBox.scrollTop = h;
} else {
this.render_dataset();
}
this._parsing=false;
}
dhtmlXGridObject.prototype._get_json_data=function(data, ind){
if (typeof data.data[ind] == "object")
return data.data[ind].value;
else
return data.data[ind];
};
dhtmlXGridObject.prototype._process_tree_json=function(data,top,pid,mode){
this._parsing=true;
var main=false;
if (!top){
this.render_row=this.render_row_tree;
main=true;
top=data;
pid=top.parent||0;
if (pid=="0") pid=0;
if (!this._h2) this._h2=new dhtmlxHierarchy();
if (this._fake) this._fake._h2=this._h2;
}
if (mode == "js"){
if (top.data && !pid)
data = top.data;
if (top.rows)
top = top.rows;
for (var i = 0; i < top.length; i++){
var id = top[i].id;
var row=this._h2.add(id,pid);
row.buff={ idd:id, data:top[i], _parser: this._process_js_row, _locator:this._get_js_data };
if (top[i].open)
row.state="minus";
this.rowsAr[id]=row.buff;
this._process_tree_json(top[i],top[i],id,mode);
}
} else {
if (top.rows) {
for (var i = 0; i < top.rows.length; i++){
var id = top.rows[i].id;
var row=this._h2.add(id,pid);
row.buff={ idd:id, data:top.rows[i], _parser: this._process_json_row, _locator:this._get_json_data };
if (top.rows[i].open)
row.state="minus";
this.rowsAr[id]=row.buff;
this._process_tree_json(top.rows[i],top.rows[i],id,mode);
}
}
}
if (main){
if (pid!=0) this._h2.change(pid,"state","minus")
this._updateTGRState(this._h2.get[pid]);
this._h2_to_buff();
if (pid!=0 && (this._srnd || this.pagingOn))
this._renderSort();
else
this.render_dataset();
if (this._slowParse===false){
this.forEachRow(function(id){
this.render_row_tree(0,id)
})
}
this._parsing=false;
if (pid!=0 && !this._srnd)
this.callEvent("onOpenEnd",[pid,1]);
}
}

View File

@ -0,0 +1,411 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
dhtmlXGridObject.prototype.enableAccessKeyMap = function(){
/*
keymap like MS Access offers
*/
this._select_ifpossible=function(){
if (this.editor && this.editor.obj && this.editor.obj.select) this.editor.obj.select();
};
this._key_events={
//ctrl-enter
k13_1_0:function(){
this.editStop();
},
//shift-enter
k13_0_1:function(){
this._key_events.k9_0_1.call(this);
},
//enter
k13_0_0:function(){
this._key_events.k9_0_0.call(this);
},
//tab
k9_0_0:function(){
this.editStop();
if (!this.callEvent("onTab",[true])) return true;
var z=this._getNextCell(null,1);
if (z) {
if (this.pagingOn) this.showRow(z.parentNode.idd);
this.selectCell(z.parentNode,z._cellIndex,(this.row!=z.parentNode),false,true);
this._still_active=true;
}
this._select_ifpossible();
},
//shift-tab
k9_0_1:function(){
this.editStop();
if (!this.callEvent("onTab",[false])) return true;
var z=this._getNextCell(null,-1);
if (z) {
this.selectCell(z.parentNode,z._cellIndex,(this.row!=z.parentNode),false,true);
this._still_active=true;
}
this._select_ifpossible();
},
//f2 key
k113_0_0:function(){
if (this._f2kE) this.editCell();
},
//space
k32_0_0:function(){
var c=this.cells4(this.cell);
if (!c.changeState || (c.changeState()===false)) return false;
},
//escape
k27_0_0:function(){
this.editStop(true);
},
//pageUp
k33_0_0:function(){
if(this.pagingOn)
this.changePage(this.currentPage-1);
else this.scrollPage(-1);
},
//pageDown
k34_0_0:function(){
if(this.pagingOn)
this.changePage(this.currentPage+1);
else this.scrollPage(1);
},
//left
k37_0_0:function(){
if (this.editor) return false;
if(this.isTreeGrid())
this.collapseKids(this.row);
else this._key_events.k9_0_1.call(this);
},
//right
k39_0_0:function(){
if (this.editor) return false;
if(!this.editor && this.isTreeGrid())
this.expandKids(this.row);
else this._key_events.k9_0_0.call(this);
},
//ctrl left
k37_1_0:function(){
if (this.editor) return false;
this.selectCell(this.row,0,false,false,true);
this._select_ifpossible();
},
//ctrl right
k39_1_0:function(){
if (this.editor) return false;
this.selectCell(this.row,this._cCount-1,false,false,true);
this._select_ifpossible();
},
//ctrl up
k38_1_0:function(){
this.selectCell(this.rowsCol[0],this.cell._cellIndex,true,false,true);
this._select_ifpossible();
},
//ctrl down
k40_1_0:function(){
this.selectCell(this.rowsCol[this.rowsCol.length-1],this.cell._cellIndex,true,false,true);
this._select_ifpossible();
},
//shift up
k38_0_1:function(){
var rowInd = this.getRowIndex(this.row.idd);
var nrow=this._nextRow(rowInd,-1);
if (!nrow || nrow._sRow || nrow._rLoad) return false;
this.selectCell(nrow,this.cell._cellIndex,true,false,true);
this._select_ifpossible();
},
//shift down
k40_0_1:function(){
var rowInd = this.getRowIndex(this.row.idd);
var nrow=this._nextRow(rowInd,1);
if (!nrow || nrow._sRow || nrow._rLoad) return false;
this.selectCell(nrow,this.cell._cellIndex,true,false,true);
this._select_ifpossible();
},
//ctrl shift up
k38_1_1:function(){
var rowInd = this.getRowIndex(this.row.idd);
for (var i = rowInd; i >= 0; i--){
this.selectCell(this.rowsCol[i],this.cell._cellIndex,true,false,true);
}
},
//ctrl shift down
k40_1_1:function(){
var rowInd = this.getRowIndex(this.row.idd);
for (var i = rowInd+1; i <this.rowsCol.length; i++){
this.selectCell(this.rowsCol[i],this.cell._cellIndex,true,false,true);
}
},
//down
k40_0_0:function(){
if (this.editor && this.editor.combo)
this.editor.shiftNext();
else{
if (!this.row.idd) return;
var rowInd = rowInd=this.getRowIndex(this.row.idd)+1;
if (this.rowsBuffer[rowInd]){
var nrow=this._nextRow(rowInd-1,1);
if (this.pagingOn && nrow) this.showRow(nrow.idd);
this._Opera_stop=0;
this.selectCell(nrow,this.cell._cellIndex,true,false,true);
}
else {
if (!this.callEvent("onLastRow", [])) return false;
this._key_events.k34_0_0.apply(this,[]);
}
}
this._still_active=true;
},
//home
k36_0_0:function(){
return this._key_events.k37_1_0.call(this);
},
//end
k35_0_0:function(){
return this._key_events.k39_1_0.call(this);
},
//ctrl-home
k36_1_0:function(){
if (this.editor || !this.rowsCol.length) return false;
this.selectCell(this.rowsCol[0],0,true,false,true);
this._select_ifpossible();
},
//ctrl-end
k35_1_0:function(){
if (this.editor || !this.rowsCol.length) return false;
this.selectCell(this.rowsCol[this.rowsCol.length-1],this._cCount-1,true,false,true);
this._select_ifpossible();
},
//padeup
k33_0_0:function(){
if(this.pagingOn)
this.changePage(this.currentPage-1);
else this.scrollPage(-1);
},
//pagedown
k34_0_0:function(){
if(this.pagingOn)
this.changePage(this.currentPage+1);
else this.scrollPage(1);
},
//up
k38_0_0:function(){
if (this.editor && this.editor.combo)
this.editor.shiftPrev();
else{
if (!this.row.idd) return;
var rowInd = rowInd=this.getRowIndex(this.row.idd)+1;
if (rowInd!=-1){
var nrow=this._nextRow(rowInd-1,-1);
this._Opera_stop=0;
if (this.pagingOn && nrow) this.showRow(nrow.idd);
this.selectCell(nrow,this.cell._cellIndex,true,false,true);
}
else this._key_events.k33_0_0.apply(this,[]);
}
this._still_active=true;
}
};
};
dhtmlXGridObject.prototype.enableExcelKeyMap = function(){
/*
keymap like MS Excel offers
*/
this._key_events={
k13_1_0:function(){
this.editStop();
},
k13_0_1:function(){
this.editStop();
this._key_events.k38_0_0.call(this);
},
k13_0_0:function(){
this.editStop();
this.callEvent("onEnter",[(this.row?this.row.idd:null),(this.cell?this.cell._cellIndex:null)]);
this._still_active=true;
this._key_events.k40_0_0.call(this);
},
k9_0_0:function(){
this.editStop();
if (!this.callEvent("onTab",[true])) return true;
if (this.cell && (this.cell._cellIndex+1)>=this._cCount) return;
var z=this._getNextCell(null,1);
if (z && this.row==z.parentNode){
this.selectCell(z.parentNode,z._cellIndex,true);
this._still_active=true;
}
},
k9_0_1:function(){
this.editStop();
if (!this.callEvent("onTab",[false])) return true;
if (this.cell && (this.cell._cellIndex==0)) return;
var z=this._getNextCell(null,-1);
if (z && this.row==z.parentNode) {
this.selectCell(z.parentNode,z._cellIndex,true);
this._still_active=true;
}
},
k113_0_0:function(){
if (this._f2kE) this.editCell();
},
k32_0_0:function(){
var c=this.cells4(this.cell);
if (!c.changeState || (c.changeState()===false)) return false;
},
k27_0_0:function(){
this.editStop(true);
this._still_active=true;
},
k33_0_0:function(){
if(this.pagingOn)
this.changePage(this.currentPage-1);
else this.scrollPage(-1);
},
k34_0_0:function(){
if(this.pagingOn)
this.changePage(this.currentPage+1);
else this.scrollPage(1);
},
k37_0_0:function(){
if (this.editor) return false;
if(this.isTreeGrid())
this.collapseKids(this.row);
else this._key_events.k9_0_1.call(this);
},
k39_0_0:function(){
if (this.editor) return false;
if(!this.editor && this.isTreeGrid())
this.expandKids(this.row);
else this._key_events.k9_0_0.call(this);
},
k37_1_0:function(){
if (this.editor) return false;
this.selectCell(this.row,0,true);
},
k39_1_0:function(){
if (this.editor) return false;
this.selectCell(this.row,this._cCount-1,true);
},
k38_1_0:function(){
if (this.editor || !this.rowsCol.length) return false;
this.selectCell(this.rowsCol[0],this.cell._cellIndex,true);
},
k40_1_0:function(){
if (this.editor || !this.rowsCol.length) return false;
this.selectCell(this.rowsCol[this.rowsCol.length-1],this.cell._cellIndex,true);
},
k38_0_1:function(){
if (this.editor || !this.rowsCol.length) return false;
var rowInd = this.row.rowIndex;
var nrow=this._nextRow(rowInd-1,-1);
if (!nrow || nrow._sRow || nrow._rLoad) return false;
this.selectCell(nrow,this.cell._cellIndex,true,true);
},
k40_0_1:function(){
if (this.editor || !this.rowsCol.length) return false;
var rowInd = this.row.rowIndex;
var nrow=this._nextRow(rowInd-1,1);
if (!nrow || nrow._sRow || nrow._rLoad) return false;
this.selectCell(nrow,this.cell._cellIndex,true,true);
},
k38_1_1:function(){
if (this.editor || !this.rowsCol.length) return false;
var rowInd = this.row.rowIndex;
for (var i = rowInd - 1; i >= 0; i--){
this.selectCell(this.rowsCol[i],this.cell._cellIndex,true,true);
}
},
k40_1_1:function(){
if (this.editor || !this.rowsCol.length) return false;
var rowInd = this.row.rowIndex;
for (var i = rowInd; i <this.rowsCol.length; i++){
this.selectCell(this.rowsCol[i],this.cell._cellIndex,true,true);
}
},
k40_0_0:function(){
var master = this._realfake?this._fake:this;
if (this.editor && this.editor.combo)
this.editor.shiftNext();
else{
if (this.editor) return false;
var rowInd = Math.max((master._r_select||0),this.getRowIndex(this.row.idd));
var row = this._nextRow(rowInd, 1);
if (row){
master._r_select=null;
this.selectCell(row, this.cell._cellIndex, true);
if (master.pagingOn) master.showRow(row.idd);
} else {
if (!this.callEvent("onLastRow", [])) return false;
this._key_events.k34_0_0.apply(this,[]);
}
}
},
k36_0_0:function(){ //home
return this._key_events.k37_1_0.call(this);
},
k35_0_0:function(){ //ctrl-home
return this._key_events.k39_1_0.call(this);
},
k36_1_0:function(){ //home
if (this.editor || !this.rowsCol.length) return false;
this.selectCell(this.rowsCol[0],0,true);
},
k35_1_0:function(){ //ctrl-end
if (this.editor || !this.rowsCol.length) return false;
this.selectCell(this.rowsCol[this.rowsCol.length-1],this._cCount-1,true);
},
k33_0_0:function(){
if(this.pagingOn)
this.changePage(this.currentPage-1);
else this.scrollPage(-1);
},
k34_0_0:function(){
if(this.pagingOn)
this.changePage(this.currentPage+1);
else this.scrollPage(1);
},
k38_0_0:function(){
var master = this._realfake?this._fake:this;
if (this.editor && this.editor.combo)
this.editor.shiftPrev();
else{
if (this.editor) return false;
if (!this.row.idd) return;
var rowInd = this.getRowIndex(this.row.idd)+1;
if (rowInd != -1 && (!this.pagingOn || (rowInd!=1))){
var nrow = this._nextRow(rowInd-1, -1);
this.selectCell(nrow, this.cell._cellIndex, true);
if (master.pagingOn && nrow) master.showRow(nrow.idd);
} else {
this._key_events.k33_0_0.apply(this,[]);
}
}
},
k_other:function(ev){
if (this.editor) return false;
if (!ev.ctrlKey && ev.keyCode>=40 && (ev.keyCode < 91 || (ev.keyCode >95 && ev.keyCode <111) || ev.keyCode > 187))
if (this.cell){
var c=this.cells4(this.cell);
if (c.isDisabled()) return false;
var t=c.getValue();
if (c.editable!==false) c.setValue("");
this.editCell();
if (this.editor) {
this.editor.val=t;
if (this.editor.obj && this.editor.obj.select)
this.editor.obj.select();
}
else c.setValue(t);
}
}
};
};

View File

@ -0,0 +1,160 @@
/*
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: sets marked cells support to enabled or disabled state
* @type: public
* @param: state - true or false
*/
dhtmlXGridObject.prototype.enableMarkedCells = function(fl){
this.markedRowsArr = new dhtmlxArray(0);
this.markedCellsArr = new Array(0);
this.lastMarkedRow = null;
this.lastMarkedColumn = null;
this.markedCells = true;
this.lastMarkMethod = 0;
if(arguments.length>0){
if(!convertStringToBoolean(fl))
this.markedCells = false;
}
};
/**
* @desc: occures on cell click
* @type: private
* @param: [el] - cell to click on
* @param: [markMethod] - 0 - simple click, 1 - shift, 2 - ctrl
*/
dhtmlXGridObject.prototype.doMark = function(el,markMethod){
var _rowId = el.parentNode.idd;
this.setActive(true);
if (!_rowId) return;
this.editStop();
this.cell=el;
this.row=el.parentNode;
var _cellIndex = el._cellIndex;
if(!markMethod) markMethod = 0;
if(markMethod==0){
this.unmarkAll() ;
}
else if(markMethod==1){
if(this.lastMarkedRow) {
var r_start = Math.min(this.getRowIndex(_rowId),this.getRowIndex(this.lastMarkedRow));
var r_end = Math.max(this.getRowIndex(_rowId),this.getRowIndex(this.lastMarkedRow));
var c_start = Math.min(_cellIndex,this.lastMarkedColumn);
var c_end = Math.max(_cellIndex,this.lastMarkedColumn);
for(var i = r_start; i < r_end+1; i++){
for(var j = c_start; j < c_end+1; j++){
this.mark(this.getRowId(i),j,true);
}
}
}
}
else if(markMethod==2){
if(this.markedRowsArr._dhx_find(_rowId)!=-1){
for(var ci = 0; ci < this.markedCellsArr[_rowId].length; ci++){
if(this.markedCellsArr[_rowId][ci]==_cellIndex){
this.mark(_rowId,_cellIndex,false);
return true;
}
}
}
}
if(!this.markedCellsArr[_rowId])
this.markedCellsArr[_rowId] = new dhtmlxArray(0);
if(markMethod!=1)
this.mark(_rowId,_cellIndex);
this.moveToVisible(this.cells(_rowId,_cellIndex).cell);
this.lastMarkedRow = _rowId;
this.lastMarkedColumn = _cellIndex;
this.lastMarkMethod = markMethod;
}
/**
* @desc: sets selection or removes selection from specified cell
* @param: r - row object or row index
* @param: cInd - cell index
* @param: state - true or false
* @type: public
*/
dhtmlXGridObject.prototype.mark = function(rid,cindex,fl){
if(arguments.length>2){
if(!convertStringToBoolean(fl)){
this.cells(rid,cindex).cell.className = this.cells(rid,cindex).cell.className.replace(/cellselected/g,"");
if(this.markedRowsArr._dhx_find(rid)!=-1){
var ci = this.markedCellsArr[rid]._dhx_find(cindex);
if(ci!=-1){
this.markedCellsArr[rid]._dhx_removeAt(ci);
if(this.markedCellsArr[rid].length==0){
this.markedRowsArr._dhx_removeAt(this.markedRowsArr._dhx_find(rid));
}
this.callEvent("onCellUnMarked",[rid,cindex]);
}
}
return true;
}
}
this.cells(rid,cindex).cell.className+= " cellselected";
if(this.markedRowsArr._dhx_find(rid)==-1)
this.markedRowsArr[this.markedRowsArr.length] = rid;
if(!this.markedCellsArr[rid])
this.markedCellsArr[rid] = new dhtmlxArray(0);
if(this.markedCellsArr[rid]._dhx_find(cindex)==-1){
this.markedCellsArr[rid][this.markedCellsArr[rid].length] = cindex;
this.callEvent("onCellMarked",[rid,cindex]);
}
}
/**
* @desc: removes selection from all marked cell
* @type: public
*/
dhtmlXGridObject.prototype.unmarkAll = function(){
if(this.markedRowsArr){
for(var ri = 0; ri < this.markedRowsArr.length; ri++){
var rid = this.markedRowsArr[ri];
if (this.rowsAr[rid])
for(var ci = 0; ci < this.markedCellsArr[rid].length; ci++){
this.callEvent("onCellUnMarked",[rid,this.markedCellsArr[rid][ci]])
this.cells(rid,this.markedCellsArr[rid][ci]).cell.className = this.cells(rid,this.markedCellsArr[rid][ci]).cell.className.replace(/cellselected/g,"");
}
}
this.markedRowsArr = new dhtmlxArray(0);
this.markedCellsArr = new Array(0);
}
return true;
}
/**
* @desc: gets marked cells
* @returns: the array of marked cells (pairs of row id and column index)
* @type: public
*/
dhtmlXGridObject.prototype.getMarked = function(){
var marked = new Array();
if(this.markedRowsArr)
for(var ri = 0; ri < this.markedRowsArr.length; ri++){
var rid = this.markedRowsArr[ri];
for(var ci = 0; ci < this.markedCellsArr[rid].length; ci++){
marked[marked.length] = [rid,this.markedCellsArr[rid][ci]];
}
}
return marked;
}

View File

@ -0,0 +1,313 @@
/*
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: cell with support for math formulas
* @param: cell - cell object
* @type: private
* @edition: Professional
*/
function eXcell_math(cell){
if (cell){
this.cell = cell;
this.grid = this.cell.parentNode.grid;
}
this.edit = function(){
this.grid.editor = new eXcell_ed(this.cell);
this.grid.editor.fix_self=true;
this.grid.editor.getValue=this.cell.original?(function(){ return this.cell.original}):this.getValue;
this.grid.editor.setValue=this.setValue;
this.grid.editor.edit();
}
this.isDisabled = function(){ return !this.grid._mathEdit; }
this.setValue = function(val){
val=this.grid._compileSCL(val,this.cell,this.fix_self);
if (this.grid._strangeParams[this.cell._cellIndex])
this.grid.cells5(this.cell,this.grid._strangeParams[this.cell._cellIndex]).setValue(val);
else{
this.setCValue(val);
this.cell._clearCell=false;
}
}
this.getValue = function(){
if (this.grid._strangeParams[this.cell._cellIndex])
return this.grid.cells5(this.cell,this.grid._strangeParams[this.cell._cellIndex]).getValue();
return this.cell.innerHTML;
}
}
eXcell_math.prototype = new eXcell;
dhtmlXGridObject.prototype._init_point_bm=dhtmlXGridObject.prototype._init_point;
dhtmlXGridObject.prototype._init_point = function(){
this._mat_links={};
this._aggregators=[];
this.attachEvent("onClearAll",function(){
this._mat_links={};
this._aggregators=[];
})
this.attachEvent("onCellChanged",function(id,ind){
if (this._mat_links[id]){
var cell=this._mat_links[id][ind];
if (cell){
for (var i=0; i<cell.length; i++)
if (cell[i].parentNode)
this.cells5(cell[i]).setValue(this._calcSCL(cell[i]));
}
}
if (!this._parsing && this._aggregators[ind]){
var pid=this._h2.get[id].parent.id;
if (pid!=0){
var ed=this.cells(pid,ind);
ed.setValue(this._calcSCL(ed.cell));
}
}
})
this.attachEvent("onAfterRowDeleted",function(id,pid){ //will be called for each delete operation, may be optimized
if (pid!=0)
if (!this._parsing && this._aggregators.length){
for (var ind=0; ind < this._aggregators.length; ind++) {
if (this._aggregators[ind]){
var ed=this.cells(pid,ind);
ed.setValue(this._calcSCL(ed.cell));
}
};
}
return true;
})
this.attachEvent("onXLE",function(){
for (var i=0; i < this._aggregators.length; i++) {
if (this._aggregators[i])
this._h2.forEachChild(0,function(el){
if (el.childs.length!=0){
var ed=this.cells(el.id,i);
ed.setValue(this._calcSCL(ed.cell));
}
},this);
};
})
this._init_point=this._init_point_bm;
if (this._init_point) this._init_point();
}
/**
* @desc: enable/disable serialization of math formulas
* @param: status - true/false
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.enableMathSerialization=function(status){
this._mathSerialization=convertStringToBoolean(status);
}
/**
* @desc: enable/disable rounding while math calculations
* @param: digits - set hom many digits must be rounded, set 0 for disabling
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.setMathRound=function(digits){
this._roundDl=digits;
this._roundD=Math.pow(10,digits);
}
/**
* @desc: enable/disable editing of math cells
* @param: status - true/false
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.enableMathEditing=function(status){
this._mathEdit=convertStringToBoolean(status);
}
/**
* @desc: calculate value of math cell
* @param: cell - math cell
* @returns: cell value
* @type: private
* @edition: Professional
*/
dhtmlXGridObject.prototype._calcSCL=function(cell){
if (!cell._code) return this.cells5(cell).getValue();
try{
dhtmlx.agrid=this;
var z=eval(cell._code);
} catch(e){ return ("#SCL"); }
if (this._roundD)
{
var pre=Math.abs(z)<1?"0":"";
if (z<0) pre="-"+pre;
z=Math.round(Math.abs(z)*this._roundD).toString();
if (z==0) return 0;
if (this._roundDl>0){
var n=z.length-this._roundDl;
if (n<0) {
z=("000000000"+z).substring(9+n);
n=0;
}
return (pre+z.substring(0,n)+"."+z.substring(n,z.length));
}
return pre+z;
}
return z;
}
dhtmlXGridObject.prototype._countTotal=function(row,cell){
var b=0;
var z=this._h2.get[row];
for (var i=0; i<z.childs.length; i++){
if (!z.childs[i].buff) return b; // dnd of item with childs, item inserted in hierarchy but not fully processed
if (z.childs[i].buff._parser){
this._h2.forEachChild(row,function(el){
if (el.childs.length==0){
var value = parseFloat(this._get_cell_value(el.buff,cell),10);
if (value)
b += value;
}
},this)
return b;
}
var value = parseFloat(this._get_cell_value(z.childs[i].buff,cell),10);
if (value)
b += value;
}
return b;
}
/**
* @desc: compile pseudo code to correct javascript
* @param: code - pseudo code
* @param: cell - math cell
* @returns: valid js code
* @type: private
* @edition: Professional
*/
dhtmlXGridObject.prototype._compileSCL=function(code,cell,fix){
if (code === null || code === window.undefined) return code;
code=code.toString();
if (code.indexOf("=")!=0 || !cell.parentNode) {
this._reLink([],cell);
if (fix) cell._code = cell.original = null;
return code;
}
cell.original=code;
var linked=null;
code=code.replace("=","");
if (code.indexOf("sum")!=-1){
code=code.replace("sum","(dhtmlx.agrid._countTotal('"+cell.parentNode.idd+"',"+cell._cellIndex+"))");
if (!this._aggregators) this._aggregators=[];
this._aggregators[cell._cellIndex]="sum";
cell._code=code;
return this._parsing?"":this._calcSCL(cell);
}
if (code.indexOf("[[")!=-1){
var test = /(\[\[([^\,]*)\,([^\]]*)]\])/g;
dhtmlx.agrid=this;
linked=linked||(new Array());
code=code.replace(test,
function ($0,$1,$2,$3){
if ($2=="-")
$2=cell.parentNode.idd;
if ($2.indexOf("#")==0)
$2=dhtmlx.agrid.getRowId($2.replace("#",""));
linked[linked.length]=[$2,$3];
return "(parseFloat(dhtmlx.agrid.cells(\""+$2+"\","+$3+").getValue(),10))";
}
);
}
if (code.indexOf(":")!=-1){
var test = /:(\w+)/g;
dhtmlx.agrid=this;
var id=cell.parentNode.idd;
linked=linked||(new Array());
code=code.replace(test,
function ($0,$1,$2,$3){
linked[linked.length]=[id,dhtmlx.agrid.getColIndexById($1)];
return '(parseFloat(dhtmlx.agrid.cells("'+id+'",dhtmlx.agrid.getColIndexById("'+$1+'")).getValue(),10))';
}
);
}
else{
var test = /c([0-9]+)/g;
dhtmlx.agrid=this;
var id=cell.parentNode.idd;
linked=linked||(new Array());
code=code.replace(test,
function ($0,$1,$2,$3){
linked[linked.length]=[id,$1];
return "(parseFloat(dhtmlx.agrid.cells(\""+id+"\","+$1+").getValue(),10))";
}
);
}
this._reLink(linked,cell);
cell._code=code;
return this._calcSCL(cell);
}
/**
* @desc: link math cells to it source cells
* @param: ar - array of nodes for linking
* @param: cell - math cell
* @type: private
* @edition: Professional
*/
dhtmlXGridObject.prototype._reLink=function(ar,cell){
if (!ar.length) return; // basically it would be good to clear unused math links, but it will require a symetric structure
for (var i=0; i<ar.length; i++){
if (!this._mat_links[ar[i][0]]) this._mat_links[ar[i][0]]={};
var t=this._mat_links[ar[i][0]];
if (!t[ar[i][1]]) t[ar[i][1]]=[];
t[ar[i][1]].push(cell);
}
}
if (_isKHTML){
// replace callback support for safari.
(function(){
var default_replace = String.prototype.replace;
String.prototype.replace = function(search,replace){
// replace is not function
if(typeof replace != "function"){
return default_replace.apply(this,arguments)
}
var str = "" + this;
var callback = replace;
// search string is not RegExp
if(!(search instanceof RegExp)){
var idx = str.indexOf(search);
return (
idx == -1 ? str :
default_replace.apply(str,[search,callback(search, idx, str)])
)
}
var reg = search;
var result = [];
var lastidx = reg.lastIndex;
var re;
while((re = reg.exec(str)) != null){
var idx = re.index;
var args = re.concat(idx, str);
result.push(
str.slice(lastidx,idx),
callback.apply(null,args).toString()
);
if(!reg.global){
lastidx += RegExp.lastMatch.length;
break
}else{
lastidx = reg.lastIndex;
}
}
result.push(str.slice(lastidx));
return result.join("")
}
})();
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,441 @@
/*
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||"&nbsp;"),(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<pz.cells.length; j++)
if (pz.cells[j]._cellIndex==ind) {
found=j;
break;
}
pind--;
}
this.hdr.rows[pind+1].cells[j].rowSpan=(this.hdr.rows[pind].cells[j].rowSpan||1)+1;
}
else
this.setHeaderCol(ind,(header[i-1]||"&nbsp;"),i);
}
else
this.setHeaderCol(ind,(header||"&nbsp;"));
this.hdr.rows[0].cells[ind]
this._cCount++;
this._cMod++;
this._master_row=null;
this.setSizes();
}
/**
* @desc: delete column
* @param: ind - index of column
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.deleteColumn=function(ind){
ind=parseInt(ind);
if (this._cCount==0) return;
if (!this._cMod) this._cMod=this._cCount;
if (ind>=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<z; i++)
this[method](this.hdr.rows[i],oldInd,newInd,i);
if (this.ftr){
var z=this.ftr.firstChild.rows.length;
for (var i=0; i<z; i++)
this[method](this.ftr.firstChild.rows[i],oldInd,newInd,i);
}
this.forEachRow(function(id){
if (this.rowsAr[id] && this.rowsAr[id].tagName=="TR")
this[method](this.rowsAr[id],oldInd,newInd,-1);
});
}
/**
* @desc: shift data in all arrays
* @type: private
* @topic: 0
*/
dhtmlXGridObject.prototype._processAllArrays = function(oldInd,newInd,vals){
var ars=["hdrLabels","initCellWidth","cellType","cellAlign","cellVAlign","fldSort","columnColor","_hrrar","_c_order"];
if (this.cellWidthPX.length) ars.push("cellWidthPX");
if (this.cellWidthPC.length) ars.push("cellWidthPC");
if (this._col_combos) ars.push("_col_combos");
if (this._mCols) ars[ars.length]="_mCols";
if (this.columnIds) ars[ars.length]="columnIds";
if (this._maskArr) ars.push("_maskArr");
if (this._drsclmW) ars.push("_drsclmW");
if (this._RaSeCol) ars.push("_RaSeCol");
if (this._hm_config) ars.push("_hm_config");
if (this._drsclmn) ars.push("_drsclmn");
if (this.clists) ars.push("clists");
if (this._validators && this._validators.data) ars.push(this._validators.data);
ars.push("combos");
if (this._customSorts) ars.push("_customSorts");
if (this._aggregators) ars.push("_aggregators");
var mode=(oldInd<=newInd);
if (!this._c_order) {
this._c_order=new Array();
var l=this._cCount;
for (var i=0; i<l; i++)
this._c_order[i]=i;
}
for (var i=0; i<ars.length; i++)
{
var t=this[ars[i]]||ars[i];
if (t){
if (mode){
var val=t[oldInd];
for (var j=oldInd; j<newInd; j++)
t[j]=t[j+1];
t[newInd]=val;
} else {
var val=t[oldInd];
for (var j=oldInd; j>(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<oldInd) var tInd=newInd+1;
else var tInd=newInd;
if (!this.callEvent("onBeforeCMove",[oldInd,tInd])) return false;
if (oldInd==tInd) return;
//replace data
this.editStop();
this._processAllRows("_moveColInRow",oldInd,newInd);
this._processAllArrays(oldInd,newInd);
//sorting image
if (this.fldSorted)
this.setSortImgPos(this.fldSorted._cellIndex);
/* for (var i=0; i<this.hdrLabels.length; i++)
this._c_revers[this._c_order[i]]=i;*/
this.callEvent("onAfterCMove",[oldInd,tInd]);
};
/**
* @desc: swap columns in collection
* @param: cols - collection of collumns
* @type: private
* @topic: 0
*/
dhtmlXGridObject.prototype._swapColumns = function(cols){
var z=new Array();
for (var i=0; i<this._cCount; i++){
var n=cols[this._c_order[i]];
if (typeof(n)=="undefined") n="";
z[i]=n;
}
return z;
}
/**
* @desc: move data in the row
* @param: row - row object
* @param: oldInd - current index of column
* @param: newInd - new index of column
* @type: private
* @topic: 0
*/
dhtmlXGridObject.prototype._moveColInRow = function(row,oldInd,newInd){
var c=row.childNodes[oldInd];
var ci=row.childNodes[newInd+1];
if (!c) return;
if (ci)
row.insertBefore(c,ci);
else
row.appendChild(c);
for (var i=0; i<row.childNodes.length; i++)
row.childNodes[i]._cellIndex=row.childNodes[i]._cellIndexS=i;
};
/**
* @desc: add column in row
* @param: row - row object
* @param: ind - current index of column
* @type: private
* @topic: 0
*/
dhtmlXGridObject.prototype._addColInRow = function(row,ind,old,mod){
var cind=ind;
if (row._childIndexes){
if (row._childIndexes[ind-1]==row._childIndexes[ind] || !row.childNodes[row._childIndexes[ind-1]]){
for (var i=row._childIndexes.length; i>=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; i<row.childNodes.length; i++){
row.childNodes[i]._cellIndex=row.childNodes[i]._cellIndexS=row.childNodes[i]._cellIndex+1;
}
if (row.childNodes[cind]) row.childNodes[cind]._cellIndex=row.childNodes[cind]._cellIndexS=ind;
if (row.idd || typeof(row.idd)!="undefined"){
this.cells3(row,ind).setValue("");
z.align=this.cellAlign[ind];
z.style.verticalAlign=this.cellVAlign[ind];
z.bgColor=this.columnColor[ind];
}
else if (z.tagName=="TD"){
if (!row.idd && this.forceDivInHeader) z.innerHTML="<div class='hdrcell'>&nbsp;</div>";
else z.innerHTML="&nbsp;";
}
};
/**
* @desc: delete columns from row
* @param: row - row object
* @param: ind - current index of column
* @type: private
* @topic: 0
*/
dhtmlXGridObject.prototype._deleteColInRow = function(row,ind){
var aind = ind; //logical index
if (row._childIndexes) ind=row._childIndexes[ind];
var c=row.childNodes[ind];
if (!c) return;
if (c.colSpan && c.colSpan>1 && 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; i<row._childIndexes.length; i++) row._childIndexes[i]--;
}
if (c)
row.removeChild(c);
for (var i=ind; i<row.childNodes.length; i++)
row.childNodes[i]._cellIndex=row.childNodes[i]._cellIndexS=row.childNodes[i]._cellIndex-1;
};
/**
* @desc: enable move column functionality
* @param: mode - true/false
* @param: columns - list of true/false values, optional
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableColumnMove = function(mode,columns){
this._mCol=convertStringToBoolean(mode);
if (typeof(columns)!="undefined")
this._mCols=columns.split(",");
if (!this._mmevTrue){
dhtmlxEvent(this.hdr,"mousedown",this._startColumnMove);
dhtmlxEvent(document.body,"mousemove",this._onColumnMove);
dhtmlxEvent(document.body,"mouseup",this._stopColumnMove);
this._mmevTrue=true;
}
};
dhtmlXGridObject.prototype._startColumnMove = function(e){
e=e||event;
var el = e.target||e.srcElement;
// var grid=globalActiveDHTMLGridObject;
var zel=el;
while(zel.tagName!="TABLE") zel=zel.parentNode;
var grid=zel.grid;
if (!grid) return; //somehow grid not found
grid.setActive();
if (!grid._mCol || e.button==2) return;
el = grid.getFirstParentOfType(el,"TD")
if(el.style.cursor!="default") return true;
if ((grid)&&(!grid._colInMove)){
grid.resized = null;
if ((!grid._mCols)||(grid._mCols[el._cellIndex]=="true"))
grid._colInMove=el._cellIndex+1;
}
return true;
};
dhtmlXGridObject.prototype._onColumnMove = function(e){
e=e||event;
var grid=window.globalActiveDHTMLGridObject;
if ((grid)&&(grid._colInMove)){
if (grid._showHContext) grid._showHContext(false)
if (typeof(grid._colInMove)!="object"){
var z=document.createElement("DIV");
z._aIndex=(grid._colInMove-1);
z._bIndex=null;
z.innerHTML=grid.getHeaderCol(z._aIndex);
z.className="dhx_dragColDiv";
z.style.position="absolute";
document.body.appendChild(z);
grid._colInMove=z;
}
var cor=[];
cor[0]=(document.body.scrollLeft||document.documentElement.scrollLeft);
cor[1]=(document.body.scrollTop||document.documentElement.scrollTop);
grid._colInMove.style.left=e.clientX+cor[0]+8+"px";
grid._colInMove.style.top=e.clientY+cor[1]+8+"px";
var el = e.target||e.srcElement;
while ((el)&&(typeof(el._cellIndexS)=="undefined"))
el=el.parentNode;
if (grid._colInMove._oldHe){
grid._colInMove._oldHe.className=grid._colInMove._oldHe.className.replace(/columnTarget(L|R)/g,"");
grid._colInMove._oldHe=null;
grid._colInMove._bIndex=null;
}
if (el) {
if (grid.hdr.rows[1]._childIndexes)
var he=grid.hdr.rows[1].cells[grid.hdr.rows[1]._childIndexes[el._cellIndexS]];
else
var he=grid.hdr.rows[1].cells[el._cellIndexS];
var z=e.clientX-(getAbsoluteLeft(he)-grid.hdrBox.scrollLeft);
if (z/he.offsetWidth>0.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

View File

@ -0,0 +1,612 @@
/*
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: load grid from CSV file
* @param: path - path to file
* @param: afterCall - function which will be called after xml loading
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.loadCSVFile = function(path,afterCall){
this.load(path,afterCall,"csv")
}
/**
* @desc: enable mode, where ID for rows loaded from CSV autogenerated
* @param: mode - true/false
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableCSVAutoID = function(mode){
this._csvAID=convertStringToBoolean(mode);
}
/**
* @desc: enable recognizing first row in CSV as header
* @param: mode - true/false
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableCSVHeader = function(mode){
this._csvHdr=convertStringToBoolean(mode);
}
/**
* @desc: load grid from CSV string
* @param: str - delimer used in CSV operations, comma by default ( only single char delimeters allowed )
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.setCSVDelimiter = function(str){
this.csv.cell=str;
}
dhtmlXGridObject.prototype._csvAID = true;
/**
* @desc: load grid from CSV string
* @param: str - CSV string
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.loadCSVString = function(str){
this.parse(str,"csv")
}
/**
* @desc: serialize to CSV string
* @type: public
* @param: text only - force serialization of text values ( skip HTML elements ) )
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.serializeToCSV = function(textmode){
this.editStop()
if (this._mathSerialization)
this._agetm="getMathValue";
else if (this._strictText || textmode)
this._agetm="getTitle";
else this._agetm="getValue";
var out=[];
if (this._csvHdr){
for (var j=1; j < this.hdr.rows.length; j++) {
var a=[];
for (var i=0; i<this._cCount; i++)
if ((!this._srClmn)||(this._srClmn[i]))
a.push(this.getColumnLabel(i,j-1));
out.push(this.csvParser.str(a,this.csv.cell, this.csv.row));
}
}
//rows collection
var i=0;
var leni=this.rowsBuffer.length;
for(i; i<leni; i++){
var temp=this._serializeRowToCVS(null,i)
if (temp!="") out.push(temp);
}
return this.csvParser.block(out,this.csv.row);
}
/**
* @desc: serialize TR to CSV
* @param: r - TR or xml node (row)
* @retruns: string - CSV representation of passed row
* @type: private
*/
dhtmlXGridObject.prototype._serializeRowToCVS = function(r,i,start,end){
var out = new Array();
if (!r){
r=this.render_row(i)
if (this._fake && !this._fake.rowsAr[r.idd]) this._fake.render_row(i);
}
if (!this._csvAID)
out[out.length]=r.idd;
start = start||0;
end = end||this._cCount;
//cells
var changeFl=false;
var ind=start;
//rowspans before block selection
while (r.childNodes[start]._cellIndex>ind && start) start--;
for(var jj=start;ind<end;jj++){
if (!r.childNodes[jj]) break;
var real_ind=r.childNodes[jj]._cellIndex;
if (((!this._srClmn)||(this._srClmn[real_ind])) && (!this._serialize_visible || !this._hrrar[real_ind])){
var cvx=r.childNodes[jj];
var zx=this.cells(r.idd,real_ind);
while (ind!=real_ind){
ind++;
out.push("")
if (ind>=end) break;
}
if (ind>=end) break;
ind++;
/* if (zx.getText)
zxVal=zx.getText();
else*/
if (zx.cell)
zxVal=zx[this._agetm]();
else zxVal="";
if ((this._chAttr)&&(zx.wasChanged()))
changeFl=true;
out[out.length]=((zxVal===null)?"":zxVal)
//#colspan:20092006{
if ( this._ecspn && cvx.colSpan && cvx.colSpan >1 ){
cvx=cvx.colSpan-1;
for (var u=0; u<cvx; u++){
out[out.length] = "";
ind++;
}
}
//#}
} else ind++;
}
if ((this._onlChAttr)&&(!changeFl)) return "";
return this.csvParser.str(out,this.csv.cell, this.csv.row);
}
dhtmlXGridObject.prototype.toClipBoard=function(val){
if (window.clipboardData)
window.clipboardData.setData("Text",val);
else
(new Clipboard()).copy(val);
}
dhtmlXGridObject.prototype.fromClipBoard=function(){
if (window.clipboardData)
return window.clipboardData.getData("Text");
else
return (new Clipboard()).paste();
}
/**
* @desc: copy value of cell to clipboard
* @type: public
* @param: rowId - id of row (optional, use selected row by default)
* @param: cellInd - column index(optional, use selected cell by default)
* @edition: Professional
* @topic: 5
*/
dhtmlXGridObject.prototype.cellToClipboard = function(rowId,cellInd){
if ((!rowId)||(!cellInd)){
if (!this.selectedRows[0]) return;
rowId=this.selectedRows[0].idd;
cellInd=this.cell._cellIndex;
}
var ed=this.cells(rowId,cellInd);
this.toClipBoard(((ed.getLabel?ed.getLabel():ed.getValue())||"").toString());
}
/**
* @desc: set value of cell from clipboard
* @type: public
* @edition: Professional
* @param: rowId - id of row (optional, use selected row by default)
* @param: cellInd - column index(optional, use selected cell by default)
* @topic: 5
*/
dhtmlXGridObject.prototype.updateCellFromClipboard = function(rowId,cellInd){
if ((!rowId)||(!cellInd)){
if (!this.selectedRows[0]) return;
rowId=this.selectedRows[0].idd;
cellInd=this.cell._cellIndex;
}
var ed=this.cells(rowId,cellInd);
ed[ed.setImage?"setLabel":"setValue"](this.fromClipBoard());
}
/**
* @desc: copy value of row to clipboard
* @type: public
* @edition: Professional
* @param: rowId - id of row (optional, use selected row by default)
* @topic: 5
*/
dhtmlXGridObject.prototype.rowToClipboard = function(rowId){
var out="";
if (this._mathSerialization)
this._agetm="getMathValue";
else if (this._strictText)
this._agetm="getTitle";
else
this._agetm="getValue";
this._serialize_visible = true;
if (rowId)
out=this._serializeRowToCVS(this.getRowById(rowId));
else {
var data = [];
for (var i=0; i<this.selectedRows.length; i++){
data[data.length] = this._serializeRowToCVS(this.selectedRows[i]);
out = this.csvParser.block(data, this.csv.row);
}
}
this._serialize_visible = false;
this.toClipBoard(out);
}
/**
* @desc: set value of row from clipboard
* @type: public
* @edition: Professional
* @param: rowId - id of row (optional, use selected row by default)
* @topic: 5
*/
dhtmlXGridObject.prototype.updateRowFromClipboard = function(rowId){
var csv=this.fromClipBoard();
if (!csv) return;
if (rowId)
var r=this.getRowById(rowId);
else
var r=this.selectedRows[0];
if (!r) return;
var parser = this.csvParser;
csv=parser.unblock(csv,this.csv.cell, this.csv.row)[0];
if (!this._csvAID) csv.splice(0,1);
for (var i=0; i<csv.length; i++){
var ed=this.cells3(r,i);
ed[ed.setImage?"setLabel":"setValue"](csv[i]);
}
}
dhtmlXGridObject.prototype.csvParser={
block:function(data,row){
return data.join(row);
},
unblock:function(str,cell,row){
var data = (str||"").split(row);
for (var i=0; i < data.length; i++)
data[i]=(data[i]||"").split(cell);
var last = data.length-1;
if (data[last].length == 1 && data[last][0]=="")
data.splice(last,1);
return data;
},
str:function(data,cell,row){
return data.join(cell);
}
};
dhtmlXGridObject.prototype.csvExtParser={
_quote:RegExp('"',"g"),
_quote_esc:RegExp("\\\\\"","g"),
block:function(data,row){
return data.join(row);
},
unblock:function(str,cell,row){
var out = [[]];
var ind = 0;
if (!str) return out;
var quote_start = /^[ ]*"/;
var quote_end = /"[ ]*$/;
var row_exp = new RegExp(".*"+row+".*$");
var data = str.split(cell);
for (var i=0; i<data.length; i++){
if (data[i].match(quote_start)){
var buff = data[i].replace(quote_start, "");
while (!data[i].match(quote_end)) {
i++;
buff+=data[i];
}
out[ind].push(buff.replace(quote_end, "").replace(this._quote_esc,'"'));
} else if (data[i].match(row_exp)){
var row_pos = data[i].indexOf(row);
out[ind].push(data[i].substr(0, row_pos));
ind++;
out[ind] = [];
data[i]=data[i].substr(row_pos+1); i--;
} else {
if (data[i] || i!=data.length-1)
out[ind].push(data[i]);
}
}
var last = out.length-1;
if (last>0 && !out[last].length)
out.splice(last,1);
return out;
},
str:function(data,cell,row){
for (var i=0; i < data.length; i++)
data[i] = '"'+data[i].replace(this._quote, "\\\"")+'"';
return data.join(cell);
}
};
/**
* @desc: add new row from clipboard
* @type: public
* @edition: Professional
* @topic: 5
*/
dhtmlXGridObject.prototype.addRowFromClipboard = function(){
var csv=this.fromClipBoard();
if (!csv) return;
var z=this.csvParser.unblock(csv, this.csv.cell, this.csv.row);
for (var i=0; i<z.length; i++)
if (z[i]){
csv=z[i];
if (!csv.length) continue;
if (this._csvAID)
this.addRow(this.getRowsNum()+2,csv);
else{
if (this.rowsAr[csv[0]])
csv[0]=this.uid();
this.addRow(csv[0],csv.slice(1));
}
}
}
/**
* @desc: copy grid in CSV to clipboard
* @type: public
* @edition: Professional
* @topic: 5
*/
dhtmlXGridObject.prototype.gridToClipboard = function(){
this.toClipBoard(this.serializeToCSV());
}
/**
* @desc: init grid from CSV stored in clipboard
* @type: public
* @edition: Professional
* @topic: 5
*/
dhtmlXGridObject.prototype.gridFromClipboard = function(){
var csv=this.fromClipBoard();
if (!csv) return;
this.loadCSVString(csv);
}
/**
* @desc: get grid as XML - php required
* @param: path - path to server side code,optional
* @type: private
* @edition: Professional
* @topic: 5
*/
dhtmlXGridObject.prototype.getXLS = function(path){
if (!this.xslform){
this.xslform=document.createElement("FORM");
this.xslform.action=(path||"")+"xls.php";
this.xslform.method="post";
this.xslform.target=(_isIE?"_blank":"");
document.body.appendChild(this.xslform);
var i1=document.createElement("INPUT");
i1.type="hidden";
i1.name="csv";
this.xslform.appendChild(i1);
var i2=document.createElement("INPUT");
i2.type="hidden";
i2.name="csv_header";
this.xslform.appendChild(i2);
}
var cvs = this.serializeToCSV();
this.xslform.childNodes[0].value = cvs;
var cvs_header = [];
var l = this._cCount;
for (var i=0; i<l; i++) {
cvs_header.push(this.getHeaderCol(i));
}
cvs_header = cvs_header.join(',');
this.xslform.childNodes[1].value = cvs_header;
this.xslform.submit();
}
/**
* @desc: generate print friendly view
* @type: public
* @edition: Professional
* @topic: 5
*/
dhtmlXGridObject.prototype.printView = function(before,after){
var html="<style>TD { font-family:Arial; text-align:center; padding-left:2px;padding-right:2px; } \n td.filter input, td.filter select { display:none; } \n </style>";
var st_hr=null;
if (this._fake) {
st_hr=[].concat(this._hrrar);
for (var i=0; i<this._fake._cCount; i++)
this._hrrar[i]=null;
}
html+="<base href='"+document.location.href+"'></base>";
if (!this.parentGrid) html+=(before||"");
html += '<table width="100%" border="2px" cellpadding="0" cellspacing="0">';
var row_length = Math.max(this.rowsBuffer.length,this.rowsCol.length); //paging and smartrendering
var col_length = this._cCount;
var width = this._printWidth();
html += '<tr class="header_row_1">';
for (var i=0; i<col_length; i++){
if (this._hrrar && this._hrrar[i]) continue;
var hcell=this.hdr.rows[1].cells[this.hdr.rows[1]._childIndexes?this.hdr.rows[1]._childIndexes[parseInt(i)]:i];
var colspan=(hcell.colSpan||1);
var rowspan=(hcell.rowSpan||1);
for (var j=1; j<colspan; j++)
width[i]+=width[j];
html += '<td rowspan="'+rowspan+'" width="'+width[i]+'%" style="background-color:lightgrey;" colspan="'+colspan+'">'+this.getHeaderCol(i)+'</td>';
i+=colspan-1;
}
html += '</tr>';
for (var i=2; i<this.hdr.rows.length; i++){
if (_isIE){
html+="<tr style='background-color:lightgrey' class='header_row_"+i+"'>";
var cells=this.hdr.rows[i].childNodes;
for (var j=0; j < cells.length; j++)
if (!this._hrrar || !this._hrrar[cells[j]._cellIndex]){
html+=cells[j].outerHTML;
}
html+="</tr>";
}
else
html+="<tr class='header_row_"+i+"' style='background-color:lightgrey'>"+(this._fake?this._fake.hdr.rows[i].innerHTML:"")+this.hdr.rows[i].innerHTML+"</tr>";
}
for (var i=0; i<row_length; i++) {
html += '<tr>';
if (this.rowsCol[i] && this.rowsCol[i]._cntr){
html+=this.rowsCol[i].innerHTML.replace(/<img[^>]*>/gi,"")+'</tr>';
continue;
}
if (this.rowsCol[i] && this.rowsCol[i].style.display=="none") continue;
var row_id
if (this.rowsCol[i])
row_id=this.rowsCol[i].idd;
else if (this.rowsBuffer[i])
row_id=this.rowsBuffer[i].idd;
else continue; //dyn loading
for (var j=0; j<col_length; j++) {
if (this._hrrar && this._hrrar[j]) continue;
if(this.rowsAr[row_id] && this.rowsAr[row_id].tagName=="TR") {
var c=this.cells(row_id, j);
if (c._setState) var value="";
else if (c.getContent) value = c.getContent();
else if (c.getImage || c.combo) var value=c.cell.innerHTML;
else var value = c.getValue();
} else
var value=this._get_cell_value(this.rowsBuffer[i],j);
var color = this.columnColor[j]?'background-color:'+this.columnColor[j]+';':'';
var align = this.cellAlign[j]?'text-align:'+this.cellAlign[j]+';':'';
var cspan = c.getAttribute("colspan");
html += '<td style="'+color+align+'" '+(cspan?'colSpan="'+cspan+'"':'')+'>'+(value===""?"&nbsp;":value)+'</td>';
if (cspan) j+=cspan-1;
}
html += '</tr>';
if (this.rowsCol[i] && this.rowsCol[i]._expanded){
var sub=this.cells4(this.rowsCol[i]._expanded.ctrl);
if (sub.getSubGrid)
html += '<tr><td colspan="'+col_length+'">'+sub.getSubGrid().printView()+'</td></tr>';
else
html += '<tr><td colspan="'+col_length+'">'+this.rowsCol[i]._expanded.innerHTML+'</td></tr>';
}
}
if (this.ftr)
for (var i=1; i<this.ftr.childNodes[0].rows.length; i++)
html+="<tr style='background-color:lightgrey'>"+((this._fake)?this._fake.ftr.childNodes[0].rows[i].innerHTML:"")+this.ftr.childNodes[0].rows[i].innerHTML+"</tr>";
html += '</table>';
if (this.parentGrid) return html;
html+=(after||"");
var d = window.open('', '_blank');
d.document.write(html);
d.document.write("<script>window.onerror=function(){return true;}</script>");
d.document.close();
if (this._fake) {
this._hrrar=st_hr;
}
}
dhtmlXGridObject.prototype._printWidth=function(){
var width = [];
var total_width = 0;
for (var i=0; i<this._cCount; i++) {
var w = this.getColWidth(i);
width.push(w);
total_width += w;
}
var percent_width = [];
var total_percent_width = 0;
for (var i=0; i<width.length; i++) {
var p = Math.floor((width[i]/total_width)*100);
total_percent_width += p;
percent_width.push(p);
}
percent_width[percent_width.length-1] += 100-total_percent_width;
return percent_width;
}
/*
user_pref("signed.applets.codebase_principal_support", true);
*/
if (!window.clipboardData)
window.clipboardData={
_make:function(){
var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip) return null;
var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans) return null;
trans.addDataFlavor('text/unicode');
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
this._p=[clip,trans,str];
return true;
},
setData:function(type,text){
try{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
} catch(e){ dhtmlxError.throwError("Clipboard","Access to clipboard denied",[type,text]); return ""; }
if (!this._make()) return false;
this._p[2].data=text;
this._p[1].setTransferData("text/unicode",this._p[2],text.length*2);
var clipid=Components.interfaces.nsIClipboard;
this._p[0].setData(this._p[1],null,clipid.kGlobalClipboard);
},
getData:function(type){
try{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
} catch(e){ dhtmlxError.throwError("Clipboard","Access to clipboard denied",[type]); return ""; }
if (!this._make()) return false;
this._p[0].getData(this._p[1],this._p[0].kGlobalClipboard);
var strLength = new Object();
var str = new Object();
try{
this._p[1].getTransferData("text/unicode",str,strLength);
} catch(e){
//empty clipboard in FF
return "";
}
if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
if (str) return str.data.substring(0,strLength.value / 2);
return "";
}
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,31 @@
/*
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
*/
dhtmlXGridObject.prototype.mouseOverHeader=function(func){
var self=this;
dhtmlxEvent(this.hdr,"mousemove",function(e){
e=e||window.event;
var el=e.target||e.srcElement;
if(el.tagName!="TD")
el = self.getFirstParentOfType(el,"TD")
if (el && (typeof(el._cellIndex)!="undefined"))
func(el.parentNode.rowIndex,el._cellIndex);
});
}
dhtmlXGridObject.prototype.mouseOver=function(func){
var self=this;
dhtmlxEvent(this.obj,"mousemove",function(e){
e=e||window.event;
var el=e.target||e.srcElement;
if(el.tagName!="TD")
el = self.getFirstParentOfType(el,"TD")
if (el && (typeof(el._cellIndex)!="undefined"))
func(el.parentNode.rowIndex,el._cellIndex);
});
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,462 @@
/*
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: enable smart paging mode
* @type: public
* @param: fl - true|false - enable|disable mode
* @param: pageSize - count of rows per page
* @param: pagesInGrp - count of visible page selectors
* @param: parentObj - ID or container which will be used for showing paging controls
* @param: showRecInfo - true|false - enable|disable showing of additional info about paging state
* @param: recInfoParentObj - ID or container which will be used for showing paging state
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enablePaging = function(fl,pageSize,pagesInGrp,parentObj,showRecInfo,recInfoParentObj){
this._pgn_parentObj = typeof(parentObj)=="string" ? document.getElementById(parentObj) : parentObj;
this._pgn_recInfoParentObj = typeof(recInfoParentObj)=="string" ? document.getElementById(recInfoParentObj) : recInfoParentObj;
this.pagingOn = fl;
this.showRecInfo = showRecInfo;
this.rowsBufferOutSize = parseInt(pageSize);
this.currentPage = 1;
this.pagesInGroup = parseInt(pagesInGrp);
this._init_pgn_events()
this.setPagingSkin("default");
}
/**
* @desc: allow to configure settings of dynamical paging
* @type: public
* @param: filePath - path which will be used for requesting data ( parth from load command used by default )
* @param: buffer - count of rows requrested from server by single operation, optional
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.setXMLAutoLoading = function(filePath,bufferSize){
this.xmlFileUrl = filePath;
this._dpref = bufferSize;
}
/**
* @desc: change current page in grid
* @type: public
* @param: ind - correction ( -1,1,2 etc) to current active page
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.changePageRelative = function(ind){
this.changePage(this.currentPage+ind);
}
/**
* @desc: change current page in grid
* @type: public
* @param: pageNum - new active page
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.changePage = function(pageNum){
if (arguments.length==0) pageNum=this.currentPage||0;
pageNum=parseInt(pageNum);
pageNum=Math.max(1,Math.min(pageNum,Math.ceil(this.rowsBuffer.length/this.rowsBufferOutSize)));
if(!this.callEvent("onBeforePageChanged",[this.currentPage,pageNum]))
return;
this.currentPage = parseInt(pageNum);
this._reset_view();
this._fixAlterCss();
this.callEvent("onPageChanged",this.getStateOfView());
}
/**
* @desc: allows to set custom paging skin
* @param: name - skin name (default,toolbar,bricks)
* @type: public
*/
dhtmlXGridObject.prototype.setPagingSkin = function(name){
this._pgn_skin=this["_pgn_"+name];
if (name=="toolbar") this._pgn_skin_tlb=arguments[1];
}
/**
* @desc: allows to set paging templates for default skin
* @param: a - template for zone A
* @param: b - template for zone B
* @type: public
*/
dhtmlXGridObject.prototype.setPagingTemplates = function(a,b){
this._pgn_templateA=this._pgn_template_compile(a);
this._pgn_templateB=this._pgn_template_compile(b);
this._page_skin_update();
}
dhtmlXGridObject.prototype._page_skin_update = function(name){
if (!this.pagesInGroup) this.pagesInGroup=Math.ceil(Math.min(5,this.rowsBuffer.length/this.rowsBufferOutSize));
var totalPages=Math.ceil(this.rowsBuffer.length/this.rowsBufferOutSize);
if (totalPages && totalPages<this.currentPage)
return this.changePage(totalPages);
if (this.pagingOn && this._pgn_skin) this._pgn_skin.apply(this,this.getStateOfView());
}
dhtmlXGridObject.prototype._init_pgn_events = function(name){
this.attachEvent("onXLE",this._page_skin_update)
this.attachEvent("onClearAll",this._page_skin_update)
this.attachEvent("onPageChanged",this._page_skin_update)
this.attachEvent("onGridReconstructed",this._page_skin_update)
this._init_pgn_events=function(){};
}
// default paging
dhtmlXGridObject.prototype._pgn_default=function(page,start,end){
if (!this.pagingBlock){
this.pagingBlock = document.createElement("DIV");
this.pagingBlock.className = "pagingBlock";
this.recordInfoBlock = document.createElement("SPAN");
this.recordInfoBlock.className = "recordsInfoBlock";
if (!this._pgn_parentObj) return;
this._pgn_parentObj.appendChild(this.pagingBlock)
if(this._pgn_recInfoParentObj && this.showRecInfo)
this._pgn_recInfoParentObj.appendChild(this.recordInfoBlock)
//this._pgn_template="{prev:} {current:-1},{current},{current:+1} {next:>}"
if (!this._pgn_templateA){
this._pgn_templateA=this._pgn_template_compile("[prevpages:&lt;:&nbsp;] [currentpages:,&nbsp;] [nextpages:&gt;:&nbsp;]");
this._pgn_templateB=this._pgn_template_compile("Results <b>[from]-[to]</b> of <b>[total]</b>");
}
}
var details=this.getStateOfView();
this.pagingBlock.innerHTML = this._pgn_templateA.apply(this,details);
this.recordInfoBlock.innerHTML = this._pgn_templateB.apply(this,details);
this._pgn_template_active(this.pagingBlock);
this._pgn_template_active(this.recordInfoBlock);
this.callEvent("onPaging",[]);
}
dhtmlXGridObject.prototype._pgn_block=function(sep){
var start=Math.floor((this.currentPage-1)/this.pagesInGroup)*this.pagesInGroup;
var max=Math.min(Math.ceil(this.rowsBuffer.length/this.rowsBufferOutSize),start+this.pagesInGroup);
var str=[];
for (var i=start+1; i<=max; i++)
if (i==this.currentPage)
str.push("<a class='dhx_not_active'><b>"+i+"</b></a>");
else
str.push("<a onclick='this.grid.changePage("+i+"); return false;'>"+i+"</a>");
return str.join(sep);
}
dhtmlXGridObject.prototype._pgn_link=function(mode,ac,ds){
if (mode=="prevpages" || mode=="prev"){
if (this.currentPage==1) return ds;
return '<a onclick=\'this.grid.changePageRelative(-1*'+(mode=="prev"?'1':'this.grid.pagesInGroup')+'); return false;\'>'+ac+'</a>'
}
if (mode=="nextpages" || mode=="next"){
if (this.rowsBuffer.length/this.rowsBufferOutSize <= this.currentPage ) return ds;
if (this.rowsBuffer.length/(this.rowsBufferOutSize*(mode=="next"?'1':this.pagesInGroup)) <= 1 ) return ds;
return '<a onclick=\'this.grid.changePageRelative('+(mode=="next"?'1':'this.grid.pagesInGroup')+'); return false;\'>'+ac+'</a>'
}
if (mode=="current"){
var i=this.currentPage+(ac?parseInt(ac):0);
if (i<1 || Math.ceil(this.rowsBuffer.length/this.rowsBufferOutSize) < i ) return ds;
return '<a '+(i==this.currentPage?"class='dhx_active_page_link' ":"")+'onclick=\'this.grid.changePage('+i+'); return false;\'>'+i+'</a>'
}
return ac;
}
dhtmlXGridObject.prototype._pgn_template_active=function(block){
var tags=block.getElementsByTagName("A");
if (tags)
for (var i=0; i < tags.length; i++) {
tags[i].grid=this;
};
}
dhtmlXGridObject.prototype._pgn_template_compile=function(template){
/*
[prev],[next]
[currentpages]
[from],[to],[total]
*/
template=template.replace(/\[([^\]]*)\]/g,function(a,b){
b=b.split(":");
switch (b[0]){
case "from":
return '"+(arguments[1]*1+(arguments[2]*1?1:0))+"';
case "total":
return '"+arguments[3]+"';
case "to":
return '"+arguments[2]+"';
case "current":
case "prev":
case "next":
case "prevpages":
case "nextpages":
return '"+this._pgn_link(\''+b[0]+'\',\''+b[1]+'\',\''+b[2]+'\')+"'
case "currentpages":
return '"+this._pgn_block(\''+b[1]+'\')+"'
}
//do it here
})
return new Function('return "'+template+'";')
}
dhtmlXGridObject.prototype.i18n.paging={
results:"Results",
records:"Records from ",
to:" to ",
page:"Page ",
perpage:"rows per page",
first:"To first Page",
previous:"Previous Page",
found:"Found records",
next:"Next Page",
last:"To last Page",
of:" of ",
notfound:"No Records Found"
}
/**
* @desc: configure paging with toolbar mode ( must be called BEFORE enablePaging)
* @param: navButtons - enable/disable navigation buttons
* @param: navLabel - enable/disable navigation label
* @param: pageSelect - enable/disable page selector
* @param: perPageSelect - an array of "per page" select options ([5,10,15,20,25,30] by default)
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.setPagingWTMode = function(navButtons,navLabel,pageSelect,perPageSelect){
this._WTDef=[navButtons,navLabel,pageSelect,perPageSelect];
}
/**
* @desc: Bricks skin for paging
*/
dhtmlXGridObject.prototype._pgn_bricks = function(page, start, end){
//set class names depending on grid skin
var tmp = (this.skin_name||"").split("_")[1];
var sfx="";
if(tmp=="light" || tmp=="modern" || tmp=="skyblue")
sfx = "_"+tmp;
this.pagerElAr = new Array();
this.pagerElAr["pagerCont"] = document.createElement("DIV");
this.pagerElAr["pagerBord"] = document.createElement("DIV");
this.pagerElAr["pagerLine"] = document.createElement("DIV");
this.pagerElAr["pagerBox"] = document.createElement("DIV");
this.pagerElAr["pagerInfo"] = document.createElement("DIV");
this.pagerElAr["pagerInfoBox"] = document.createElement("DIV");
var se = (this.globalBox||this.objBox);
this.pagerElAr["pagerCont"].style.width = se.clientWidth+"px";
this.pagerElAr["pagerCont"].style.overflow = "hidden";
this.pagerElAr["pagerCont"].style.clear = "both";
this.pagerElAr["pagerBord"].className = "dhx_pbox"+sfx;
this.pagerElAr["pagerLine"].className = "dhx_pline"+sfx;
this.pagerElAr["pagerBox"].style.clear = "both";
this.pagerElAr["pagerInfo"].className = "dhx_pager_info"+sfx;
//create structure
this.pagerElAr["pagerCont"].appendChild(this.pagerElAr["pagerBord"]);
this.pagerElAr["pagerCont"].appendChild(this.pagerElAr["pagerLine"]);
this.pagerElAr["pagerCont"].appendChild(this.pagerElAr["pagerInfo"]);
this.pagerElAr["pagerLine"].appendChild(this.pagerElAr["pagerBox"]);
this.pagerElAr["pagerInfo"].appendChild(this.pagerElAr["pagerInfoBox"]);
this._pgn_parentObj.innerHTML = "";
this._pgn_parentObj.appendChild(this.pagerElAr["pagerCont"]);
if(this.rowsBuffer.length>0){
var lineWidth = 20;
var lineWidthInc = 22;
//create left arrow if needed
if(page>this.pagesInGroup){
var pageCont = document.createElement("DIV");
var pageBox = document.createElement("DIV");
pageCont.className = "dhx_page"+sfx;
pageBox.innerHTML = "&larr;";
pageCont.appendChild(pageBox);
this.pagerElAr["pagerBox"].appendChild(pageCont);
var self = this;
pageCont.pgnum = (Math.ceil(page/this.pagesInGroup)-1)*this.pagesInGroup;
pageCont.onclick = function(){
self.changePage(this.pgnum);
}
lineWidth +=lineWidthInc;
}
//create pages
for(var i=1;i<=this.pagesInGroup;i++){
var pageCont = document.createElement("DIV");
var pageBox = document.createElement("DIV");
pageCont.className = "dhx_page"+sfx;
pageNumber = ((Math.ceil(page/this.pagesInGroup)-1)*this.pagesInGroup)+i;
if(pageNumber>Math.ceil(this.rowsBuffer.length/this.rowsBufferOutSize))
break;
pageBox.innerHTML = pageNumber;
pageCont.appendChild(pageBox);
if(page==pageNumber){
pageCont.className += " dhx_page_active"+sfx;
pageBox.className = "dhx_page_active"+sfx;
}else{
var self = this;
pageCont.pgnum = pageNumber;
pageCont.onclick = function(){
self.changePage(this.pgnum);
}
}
lineWidth +=(parseInt(lineWidthInc/3)*pageNumber.toString().length)+15;
pageBox.style.width = (parseInt(lineWidthInc/3)*pageNumber.toString().length)+8+"px";
this.pagerElAr["pagerBox"].appendChild(pageCont);
}
//create right arrow if needed
if(Math.ceil(page/this.pagesInGroup)*this.pagesInGroup<Math.ceil(this.rowsBuffer.length/this.rowsBufferOutSize)){
var pageCont = document.createElement("DIV");
var pageBox = document.createElement("DIV");
pageCont.className = "dhx_page"+sfx;
pageBox.innerHTML = "&rarr;";
pageCont.appendChild(pageBox);
this.pagerElAr["pagerBox"].appendChild(pageCont);
var self = this;
pageCont.pgnum = (Math.ceil(page/this.pagesInGroup)*this.pagesInGroup)+1;
pageCont.onclick = function(){
self.changePage(this.pgnum);
}
lineWidth +=lineWidthInc;
}
this.pagerElAr["pagerLine"].style.width = lineWidth+"px";
}
//create page info
if(this.rowsBuffer.length>0 && this.showRecInfo)
this.pagerElAr["pagerInfoBox"].innerHTML = this.i18n.paging.records+(start+1)+this.i18n.paging.to+end+this.i18n.paging.of+this.rowsBuffer.length;
else if(this.rowsBuffer.length==0){
this.pagerElAr["pagerLine"].parentNode.removeChild(this.pagerElAr["pagerLine"]);
this.pagerElAr["pagerInfoBox"].innerHTML = this.i18n.paging.notfound;
}
//add whitespaces where necessary
this.pagerElAr["pagerBox"].appendChild(document.createElement("SPAN")).innerHTML = "&nbsp;";
this.pagerElAr["pagerBord"].appendChild(document.createElement("SPAN")).innerHTML = "&nbsp;";
this.pagerElAr["pagerCont"].appendChild(document.createElement("SPAN")).innerHTML = "&nbsp;";
this.callEvent("onPaging",[]);
}
/**
* @desc: web toolbar skin for paging
*/
dhtmlXGridObject.prototype._pgn_toolbar = function(page, start, end){
if (!this.aToolBar) this.aToolBar = this._pgn_createToolBar();
var totalPages=Math.ceil(this.rowsBuffer.length/this.rowsBufferOutSize);
if (this._WTDef[0]){
this.aToolBar.enableItem("right");
this.aToolBar.enableItem("rightabs");
this.aToolBar.enableItem("left");
this.aToolBar.enableItem("leftabs");
if(this.currentPage>=totalPages){
this.aToolBar.disableItem("right");
this.aToolBar.disableItem("rightabs");
}
if(this.currentPage==1){
this.aToolBar.disableItem("left");
this.aToolBar.disableItem("leftabs");
}
}
if (this._WTDef[2]){
var that = this;
this.aToolBar.forEachListOption("pages", function(id){
that.aToolBar.removeListOption("pages", id);
});
var w = {dhx_skyblue: 4, dhx_web: 0, dhx_terrace: 14}[this.aToolBar.conf.skin];
for (var i=0; i<totalPages; i++) {
this.aToolBar.addListOption("pages", "pages_"+(i+1), NaN, "button", "<span style='padding: 0px "+w+"px 0px 0px;'>"+this.i18n.paging.page+(i+1)+"</span>", "paging_page.gif");
}
this.aToolBar.setItemText("pages", this.i18n.paging.page+page);
}
// pButton.setSelected(page.toString())
if (this._WTDef[1]){
if (!this.getRowsNum())
this.aToolBar.setItemText('results',this.i18n.paging.notfound);
else
this.aToolBar.setItemText('results',"<div style='width:100%; text-align:center'>"+this.i18n.paging.records+(start+1)+this.i18n.paging.to+end+"</div>");
}
if (this._WTDef[3])
this.aToolBar.setItemText("perpagenum", this.rowsBufferOutSize.toString()+" "+this.i18n.paging.perpage);
this.callEvent("onPaging",[]);
}
dhtmlXGridObject.prototype._pgn_createToolBar = function(){
this.aToolBar = new dhtmlXToolbarObject({
parent: this._pgn_parentObj,
skin: (this._pgn_skin_tlb||this.skin_name),
icons_path: this.imgURL
});
if (!this._WTDef) this.setPagingWTMode(true, true, true, true);
var self = this;
this.aToolBar.attachEvent("onClick", function(val){
val = val.split("_");
switch (val[0]){
case "leftabs":
self.changePage(1);
break;
case "left":
self.changePage(self.currentPage-1);
break;
case "rightabs":
self.changePage(99999);
break;
case "right":
self.changePage(self.currentPage+1);
break;
case "perpagenum":
if (val[1]===this.undefined) return;
self.rowsBufferOutSize = parseInt(val[1]);
self.changePage();
self.aToolBar.setItemText("perpagenum", val[1]+" "+self.i18n.paging.perpage);
break;
case "pages":
if (val[1]===this.undefined) return;
self.changePage(val[1]);
self.aToolBar.setItemText("pages", self.i18n.paging.page+val[1]);
break;
}
});
// add buttons
if (this._WTDef[0]) {
this.aToolBar.addButton("leftabs", NaN, null, "ar_left_abs.gif", "ar_left_abs_dis.gif");
this.aToolBar.addButton("left", NaN, null, "ar_left.gif", "ar_left_dis.gif");
}
if (this._WTDef[1]) {
this.aToolBar.addText("results", NaN, this.i18n.paging.results);
this.aToolBar.setWidth("results", "150");
this.aToolBar.disableItem("results");
}
if (this._WTDef[0]) {
this.aToolBar.addButton("right", NaN, null, "ar_right.gif", "ar_right_dis.gif");
this.aToolBar.addButton("rightabs", NaN, null, "ar_right_abs.gif", "ar_right_abs_dis.gif");
}
if (this._WTDef[2]) {
if (this.aToolBar.conf.skin == "dhx_terrace") this.aToolBar.addSeparator();
this.aToolBar.addButtonSelect("pages", NaN, "select page", [], "paging_pages.gif", null, false, true);
}
var arr;
if (arr = this._WTDef[3]) {
if (this.aToolBar.conf.skin == "dhx_terrace") this.aToolBar.addSeparator();
this.aToolBar.addButtonSelect("perpagenum", NaN, "select size", [], "paging_rows.gif", null, false, true);
if (typeof arr != "object") arr = [5,10,15,20,25,30];
var w = {dhx_skyblue: 4, dhx_web: 0, dhx_terrace: 18}[this.aToolBar.conf.skin];
for (var k=0; k<arr.length; k++) {
this.aToolBar.addListOption("perpagenum", "perpagenum_"+arr[k], NaN, "button", "<span style='padding: 0px "+w+"px 0px 0px;'>"+arr[k]+" "+this.i18n.paging.perpage+"</span>", "paging_page.gif");
}
}
//var td = document.createElement("TD"); td.width = "5"; this.aToolBar.tr.appendChild(td);
//var td = document.createElement("TD"); td.width = "100%"; this.aToolBar.tr.appendChild(td);
return this.aToolBar;
}

View File

@ -0,0 +1,314 @@
/*
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: hide pivot table related to grid, if any exists, switch grid back to normal mode
* @type: public
* @topic: 0
*/
dhtmlXGridObject.prototype.hidePivot=function(cont){
if (this._pgridCont){
if (this._pgrid) this._pgrid.destructor();
var c=this._pgridCont.parentNode;
c.innerHTML="";
if (c.parentNode==this.entBox)
this.entBox.removeChild(c);
this._pgrid=this._pgridSelect=this._pUNI=this._pgridCont=null;
}
}
/**
* @desc: show pivot table based on grid
* @type: public
* @param: cont - html container in which pivot rendered, but default pivot will be rendered over existing grid
* details: collection of settings; details.column_list - list of columns used in pivot selects; details.readonly - created pivot with fixed configuration, details.action, details.value, action.x, action.y - default values for 4 pivot's selects
* @topic: 0
*/
dhtmlXGridObject.prototype.makePivot=function(cont,details){
details=details||{};
this.hidePivot();
if (!cont){
var cont=document.createElement("DIV");
cont.style.cssText="position:absolute; top:0px; left:0px;background-color:white;";
cont.style.height=this.entBox.offsetHeight+"px";
cont.style.width=this.entBox.offsetWidth+"px";
if (this.entBox.style.position!="absolute")
this.entBox.style.position="relative";
this.entBox.appendChild(cont);
}
if (typeof(cont)!="object") cont=document.getElementById(cont)
if (details.column_list)
this._column_list=details.column_list;
else{
this._column_list=[];
for (var i=0; i<this.hdr.rows[1].cells.length; i++)
this._column_list.push(this.hdr.rows[1].cells[i][_isIE?"innerText":"textContent"])
}
var that = this;
cont.innerHTML="<table cellspacing='0' cellpadding='0'><tr><td style='width:160px' align='center'></td><td>&nbsp;&nbsp;&nbsp;</td><td></td></tr></table><div></div>";
var z1=this.makePivotSelect(this._column_list);
z1.style.width="80px";
z1.onchange=function(){
if (this.value!=-1)
that._pivotS.value=this.value;
else that._pivotS.value="";
that._reFillPivotLists();
that._renderPivot2();
}
var z2=this.makePivotSelect(this._column_list);
z2.onchange=function(){
if (this.value!=-1)
that._pivotS.x=this.value;
else that._pivotS.x="";
that._reFillPivotLists();
that._renderPivot()
}
var z3=this.makePivotSelect(this._column_list);
z3.onchange=function(){
if (this.value!=-1)
that._pivotS.y=this.value;
else that._pivotS.y="";
that._reFillPivotLists();
that._renderPivot()
}
var z4=this.makePivotSelect(["Sum","Min","Max","Average","Count"],-1);
z4.style.width="70px";
z4.onchange=function(){
if (this.value!=-1)
that._pivotS.action=this.value;
else that._pivotS.action=null;
that._renderPivot2();
}
if (details.readonly)
z1.disabled=z2.disabled=z3.disabled=z4.disabled=true;
cont.firstChild.rows[0].cells[0].appendChild(z4);
cont.firstChild.rows[0].cells[0].appendChild(z1);
cont.firstChild.rows[0].cells[2].appendChild(z2);
var gr=cont.childNodes[1];
gr.style.width=cont.offsetWidth+"px";
gr.style.height=cont.offsetHeight-20+"px";
gr.style.overflow="hidden";
this._pgridCont=gr;
this._pgridSelect=[z1,z2,z3,z4];
this._pData=this._fetchPivotData();
this._pUNI=[];
this._pivotS={ action:(details.action||"0"), value:(typeof details.value != "undefined" ? (details.value||"0") : null), x:(typeof details.x != "undefined" ? (details.x||"0") : null), y:(typeof details.y != "undefined" ? (details.y||"0") : null) };
z1.value=this._pivotS.value;
z2.value=this._pivotS.x;
z3.value=this._pivotS.y;
z4.value=this._pivotS.action;
that._reFillPivotLists();
this._renderPivot();
}
dhtmlXGridObject.prototype._fetchPivotData=function(){
var z=[];
for (var i=0; i<this._cCount; i++) {
var d=[];
for (var j=0; j<this.rowsCol.length; j++) {
if (this.rowsCol[j]._cntr) continue;
d.push(this.cells2(j,i).getValue()); //TODO : excell caching
}
z.push(d)
}
return z;
}
dhtmlXGridObject.prototype._renderPivot=function(){
if (_isIE) this._pgridSelect[2].removeNode(true)
if (this._pgrid)
this._pgrid.destructor();
this._pgrid=new dhtmlXGridObject(this._pgridCont);
this._pgrid.setImagePath(this.imgURL);
this._pgrid.attachEvent("onBeforeSelect",function(){return false;});
if (this._pivotS.x){
var l=this._getUniList(this._pivotS.x);
var s=[160];
for (var i=0; i < l.length; i++)
s.push(100);
l=[""].concat(l)
this._pgrid.setHeader(l);
this._pgrid.setInitWidths(s.join(","));
} else {
this._pgrid.setHeader("");
this._pgrid.setInitWidths("160");
}
this._pgrid.init();
this._pgrid.setEditable(false);
this._pgrid.setSkin(this.entBox.className.replace("gridbox gridbox_",""));
var t=this._pgrid.hdr.rows[1].cells[0];
if (t.firstChild && t.firstChild.tagName=="DIV") t=t.firstChild;
t.appendChild(this._pgridSelect[2]);
this._pgrid.setSizes();
if (this._pivotS.y){
var l=this._getUniList(this._pivotS.y);
for (var i=0; i < l.length; i++) {
this._pgrid.addRow(this._pgrid.uid(),[l[i]],-1);
};
} else {
this._pgrid.addRow(1,"not ready",1);
}
this._renderPivot2();
}
dhtmlXGridObject.prototype._pivot_action_0=function(a,b,c,av,bv,data){
var ret=0;
var resA=data[a];
var resB=data[b];
var resC=data[c];
for (var i = resA.length - 1; i >= 0; i--)
if (resA[i]==av && resB[i]==bv)
ret+=this.parseFloat(resC[i]);
return ret;
}
dhtmlXGridObject.prototype._pivot_action_1=function(a,b,c,av,bv,data){
ret=9999999999;
var resA=data[a];
var resB=data[b];
var resC=data[c];
for (var i = resA.length - 1; i >= 0; i--)
if (resA[i]==av && resB[i]==bv)
ret=Math.min(this.parseFloat(resC[i]),ret);
if (ret==9999999999) ret="";
return ret;
}
dhtmlXGridObject.prototype._pivot_action_2=function(a,b,c,av,bv,data){
ret=-9999999999;
var resA=data[a];
var resB=data[b];
var resC=data[c];
for (var i = resA.length - 1; i >= 0; i--)
if (resA[i]==av && resB[i]==bv)
ret=Math.max(this.parseFloat(resC[i]),ret);
if (ret==-9999999999) ret="";
return ret;
}
dhtmlXGridObject.prototype._pivot_action_3=function(a,b,c,av,bv,data){
var ret=0;
var count=0;
var resA=data[a];
var resB=data[b];
var resC=data[c];
for (var i = resA.length - 1; i >= 0; i--)
if (resA[i]==av && resB[i]==bv) {
ret+=this.parseFloat(resC[i]);
count++;
}
return count?ret/count:"";
}
dhtmlXGridObject.prototype._pivot_action_4=function(a,b,c,av,bv,data){
var ret=0;
var count=0;
var resA=data[a];
var resB=data[b];
var resC=data[c];
for (var i = resA.length - 1; i >= 0; i--)
if (resA[i]==av && resB[i]==bv) {
ret++;
}
return ret;
}
dhtmlXGridObject.prototype.parseFloat = function(val){
val = parseFloat(val);
if (isNaN(val)) return 0;
return val;
}
dhtmlXGridObject.prototype._renderPivot2=function(){
if (!(this._pivotS.x && this._pivotS.y && this._pivotS.value && this._pivotS.action)) return;
var action=this["_pivot_action_"+this._pivotS.action];
var x=this._getUniList(this._pivotS.x);
var y=this._getUniList(this._pivotS.y);
for (var i=0; i < x.length; i++) {
for (var j=0; j < y.length; j++) {
this._pgrid.cells2(j,i+1).setValue(Math.round(action(this._pivotS.x,this._pivotS.y,this._pivotS.value,x[i],y[j],this._pData)*100)/100);
};
};
}
dhtmlXGridObject.prototype._getUniList=function(col){
if (!this._pUNI[col]){
var t={};
var a=[];
for (var i = this._pData[col].length - 1; i >= 0; i--){
t[this._pData[col][i]]=true;
}
for (var n in t)
if (t[n]===true) a.push(n);
this._pUNI[col]=a.sort();
}
return this._pUNI[col];
}
dhtmlXGridObject.prototype._fillPivotList=function(z,list,miss,v){
if (!miss){
miss={};
v=-1;
}
z.innerHTML="";
z.options[z.options.length]=new Option("-select-",-1);
for (var i=0; i<list.length; i++){
if (miss[i] || list[i]===null) continue;
z.options[z.options.length]=new Option(list[i],i);
}
z.value=parseInt(v);
}
dhtmlXGridObject.prototype._reFillPivotLists=function(){
var s=[]; var v=[];
for (var i=0; i<3; i++){
s.push(this._pgridSelect[i]);
v.push(s[i].value);
}
var t=this._reFfillPivotLists;
var m={}; m[v[1]]=m[v[2]]=true;
this._fillPivotList(s[0],this._column_list,m,v[0]);
m={}; m[v[0]]=m[v[2]]=true;
this._fillPivotList(s[1],this._column_list,m,v[1]);
m={}; m[v[1]]=m[v[0]]=true;
this._fillPivotList(s[2],this._column_list,m,v[2]);
this._reFfillPivotLists=t;
}
dhtmlXGridObject.prototype.makePivotSelect=function(list,miss){
var z=document.createElement("SELECT");
this._fillPivotList(z,list,miss);
z.style.cssText="width:150px; height:20px; font-family:Tahoma; font-size:8pt; font-weight:normal;";
return z;
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,32 @@
/*
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
*/
dhtmlXGridObject.prototype.post=function(url, post, call, type){
this.callEvent("onXLS", [this]);
if (arguments.length == 3 && typeof call != "function"){
type=call;
call=null;
}
type=type||"xml";
post=post||"";
if (!this.xmlFileUrl)
this.xmlFileUrl=url;
this._data_type=type;
this.xmlLoader.onloadAction=function(that, b, c, d, xml){
xml=that["_process_"+type](xml);
if (!that._contextCallTimer)
that.callEvent("onXLE", [that,0,0,xml]);
if (call){
call();
call=null;
}
}
this.xmlLoader.loadXML(url,true,post);
}

View File

@ -0,0 +1,141 @@
/*
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: set rowspan with specified length starting from specified cell
* @param: rowID - row Id
* @param: colInd - column index
* @param: length - length of rowspan
* @edition: professional
* @type: public
*/
dhtmlXGridObject.prototype.setRowspan=function(rowID,colInd,length){
var c=this[this._bfs_cells?"_bfs_cells":"cells"](rowID,colInd).cell;
var r=this.rowsAr[rowID];
if (c.rowSpan && c.rowSpan!=1){
var ur=r.nextSibling;
for (var i=1; i<c.rowSpan; i++){
var tc=ur.childNodes[ur._childIndexes[c._cellIndex+1]]
var ti=document.createElement("TD");
ti.innerHTML="&nbsp;";
ti._cellIndex=c._cellIndex;
ti._clearCell=true;
if (tc)
tc.parentNode.insertBefore(ti,tc);
else
ur.parentNode.appendChild(ti);
this._shiftIndexes(ur,c._cellIndex,-1);
ur=ur.nextSibling;
}
}
c.rowSpan=length;
if (!this._h2)
r=r.nextSibling||this.rowsCol[this.rowsCol._dhx_find(r)+1];
else
r=this.rowsAr[ this._h2.get[r.idd].parent.childs[this._h2.get[r.idd].index+1].id ];
var kids=[];
for (var i=1; i<length; i++){
var ct=null;
if (this._fake && !this._realfake)
ct=this._bfs_cells3(r,colInd).cell;
else
ct=this.cells3(r,colInd).cell;
this._shiftIndexes(r,c._cellIndex,1);
if (ct)
ct.parentNode.removeChild(ct);
kids.push(r);
if (!this._h2)
r=r.nextSibling||this.rowsCol[this.rowsCol._dhx_find(r)+1];
else {
var r=this._h2.get[r.idd].parent.childs[this._h2.get[r.idd].index+1];
if (r) r=this.rowsAr[ r.id ];
}
}
this.rowsAr[rowID]._rowSpan=this.rowsAr[rowID]._rowSpan||{};
this.rowsAr[rowID]._rowSpan[colInd]=kids;
if (this._fake && !this._realfake && colInd<this._fake._cCount)
this._fake.setRowspan(rowID,colInd,length)
}
dhtmlXGridObject.prototype._shiftIndexes=function(r,pos,ind){
if (!r._childIndexes){
r._childIndexes=new Array();
for (var z=0; z<r.childNodes.length; z++)
r._childIndexes[z]=z;
}
for (var z=0; z<r._childIndexes.length; z++)
if (z>pos)
r._childIndexes[z]=r._childIndexes[z]-ind;
}
/**
* @desc: enable rowspan in grid
* @type: public
* @edition: professional
*/
dhtmlXGridObject.prototype.enableRowspan=function(){
this._erspan=true;
this.enableRowspan=function(){};
this.attachEvent("onAfterSorting",function(){
if (this._dload) return; //can't be helped
for (var i=1; i<this.obj.rows.length; i++)
if (this.obj.rows[i]._rowSpan){
var master=this.obj.rows[i];
for (var kname in master._rowSpan){
var row=master;
var kids=row._rowSpan[kname];
for (var j=0; j < kids.length; j++) {
if(row.nextSibling)
row.parentNode.insertBefore(kids[j],row.nextSibling);
else
row.parentNode.appendChild(kids[j]);
if (this._fake){ // split mode
var frow=this._fake.rowsAr[row.idd];
var fkid=this._fake.rowsAr[kids[j].idd];
if(frow.nextSibling)
frow.parentNode.insertBefore(fkid,frow.nextSibling);
else
frow.parentNode.appendChild(fkid);
this._correctRowHeight(row.idd);
}
row=row.nextSibling;
}
}
}
var t = this.rowsCol.stablesort;
this.rowsCol=new dhtmlxArray();
this.rowsCol.stablesort=t;
for (var i=1; i<this.obj.rows.length; i++)
this.rowsCol.push(this.obj.rows[i]);
})
this.attachEvent("onXLE",function(a,b,c,xml){
for (var i=0; i<this.rowsBuffer.length; i++){
var row = this.render_row(i);
var childs = row.childNodes;
for (var j=0; j<childs.length; j++){
if (childs[j]._attrs["rowspan"]){
this.setRowspan(row.idd,j,childs[j]._attrs["rowspan"]);
}
}
}
});
}

View File

@ -0,0 +1,457 @@
/*
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: enables block selection mode in grid
* @type: public
* @topic: 0
*/
dhtmlXGridObject.prototype.enableBlockSelection = function(mode)
{
if (typeof this._bs_mode == "undefined"){
var self = this;
this.obj.onmousedown = function(e) {
if (self._bs_mode) self._OnSelectionStart((e||event),this); return true;
}
this._CSVRowDelimiter = this.csv.row;
this.attachEvent("onResize", function() {self._HideSelection(); return true;});
this.attachEvent("onGridReconstructed", function() {self._HideSelection(); return true;});
this.attachEvent("onFilterEnd",this._HideSelection);
}
if (mode===false){
this._bs_mode=false;
return this._HideSelection();
} else this._bs_mode=true;
var area = this._clip_area = document.createElement("textarea");
area.style.cssText = "position:absolute; width:1px; height:1px; overflow:hidden; color:transparent; background-color:transparent; bottom:1px; right:1px; border:none;";
area.onkeydown=function(e){
e=e||event;
if (e.keyCode == 86 && (e.ctrlKey || e.metaKey))
self.pasteBlockFromClipboard()
};
document.body.insertBefore(this._clip_area,document.body.firstChild);
dhtmlxEvent(this.entBox,"click",function(){
if (!self.editor)
self._clip_area.select();
});
}
/**
* @desc: affect block selection, so it will copy|paste only visible text , not values behind
* @param: mode - true/false
* @type: public
* @topic: 0
*/
dhtmlXGridObject.prototype.forceLabelSelection = function(mode)
{
this._strictText = convertStringToBoolean(mode)
}
dhtmlXGridObject.prototype._OnSelectionStart = function(event, obj)
{
var self = this;
if (event.button == 2) return;
var src = event.srcElement || event.target;
if (this.editor){
if (src.tagName && (src.tagName=="INPUT" || src.tagName=="TEXTAREA")) return;
this.editStop();
}
self.setActive(true);
var pos = this.getPosition(this.obj);
var x = event.clientX - pos[0] + (document.body.scrollLeft||(document.documentElement?document.documentElement.scrollLeft:0));
var y = event.clientY - pos[1] + (document.body.scrollTop||(document.documentElement?document.documentElement.scrollTop:0));
this._CreateSelection(x-4, y-4);
if (src == this._selectionObj) {
this._HideSelection();
this._startSelectionCell = null;
} else {
while (src && (!src.tagName || src.tagName.toLowerCase() != 'td'))
src = src.parentNode;
this._startSelectionCell = src;
}
if (this._startSelectionCell){
if (!this.callEvent("onBeforeBlockSelected",[this._startSelectionCell.parentNode.idd, this._startSelectionCell._cellIndex]))
return this._startSelectionCell = null;
}
//this._ShowSelection();
this.obj.onmousedown = null;
this.obj[_isIE?"onmouseleave":"onmouseout"] = function(e){ if (self._blsTimer) window.clearTimeout(self._blsTimer); };
this.obj.onmmold=this.obj.onmousemove;
this._init_pos=[x,y];
this._selectionObj.onmousemove = this.obj.onmousemove = function(e) {e = e||event; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; self._OnSelectionMove(e);}
this._oldDMP=document.body.onmouseup;
document.body.onmouseup = function(e) {e = e||event; self._OnSelectionStop(e, this); return true; }
this.callEvent("onBeforeBlockSelection",[]);
document.body.onselectstart = function(){return false};//avoid text select
}
dhtmlXGridObject.prototype._getCellByPos = function(x,y){
x=x;//+this.objBox.scrollLeft;
if (this._fake)
x+=this._fake.objBox.scrollWidth;
y=y;//+this.objBox.scrollTop;
var _x=0;
for (var i=0; i < this.obj.rows.length; i++) {
y-=this.obj.rows[i].offsetHeight;
if (y<=0) {
_x=this.obj.rows[i];
break;
}
}
if (!_x || !_x.idd) return null;
for (var i=0; i < this._cCount; i++) {
x-=this.getColWidth(i);
if (x<=0) {
while(true){
if (_x._childIndexes && _x._childIndexes[i+1]==_x._childIndexes[i])
_x=_x.previousSibling;
else {
return this.cells(_x.idd,i).cell;
}
}
}
}
return null;
}
dhtmlXGridObject.prototype._OnSelectionMove = function(event)
{
var self=this;
this._ShowSelection();
var pos = this.getPosition(this.obj);
var X = event.clientX - pos[0] + (document.body.scrollLeft||(document.documentElement?document.documentElement.scrollLeft:0));
var Y = event.clientY - pos[1] + (document.body.scrollTop||(document.documentElement?document.documentElement.scrollTop:0));
if ((Math.abs(this._init_pos[0]-X)<5) && (Math.abs(this._init_pos[1]-Y)<5)) return this._HideSelection();
var temp = this._endSelectionCell;
if(this._startSelectionCell==null)
this._endSelectionCell = this._startSelectionCell = this.getFirstParentOfType(event.srcElement || event.target,"TD");
else
if (event.srcElement || event.target) {
if ((event.srcElement || event.target).className == "dhtmlxGrid_selection")
this._endSelectionCell=(this._getCellByPos(X,Y)||this._endSelectionCell);
else {
var t = this.getFirstParentOfType(event.srcElement || event.target,"TD");
if (t.parentNode.idd) this._endSelectionCell = t;
}
}
if (this._endSelectionCell){
if (!this.callEvent("onBeforeBlockSelected",[this._endSelectionCell.parentNode.idd, this._endSelectionCell._cellIndex]))
this._endSelectionCell = temp;
}
/*
//window.status = pos[0]+'+'+pos[1];
var prevX = this._selectionObj.startX;
var prevY = this._selectionObj.startY;
var diffX = X - prevX;
var diffY = Y - prevY;
if (diffX < 0) {
this._selectionObj.style.left = this._selectionObj.startX + diffX + 1+"px";
diffX = 0 - diffX;
} else {
this._selectionObj.style.left = this._selectionObj.startX - 3+"px";
}
if (diffY < 0) {
this._selectionObj.style.top = this._selectionObj.startY + diffY + 1+"px";
diffY = 0 - diffY;
} else {
this._selectionObj.style.top = this._selectionObj.startY - 3+"px";
}
this._selectionObj.style.width = (diffX>4?diffX-4:0) + 'px';
this._selectionObj.style.height = (diffY>4?diffY-4:0) + 'px';
/* AUTO SCROLL */
var BottomRightX = this.objBox.scrollLeft + this.objBox.clientWidth;
var BottomRightY = this.objBox.scrollTop + this.objBox.clientHeight;
var TopLeftX = this.objBox.scrollLeft;
var TopLeftY = this.objBox.scrollTop;
var nextCall=false;
if (this._blsTimer) window.clearTimeout(this._blsTimer);
if (X+20 >= BottomRightX) {
this.objBox.scrollLeft = this.objBox.scrollLeft+20;
nextCall=true;
} else if (X-20 < TopLeftX) {
this.objBox.scrollLeft = this.objBox.scrollLeft-20;
nextCall=true;
}
if (Y+20 >= BottomRightY && !this._realfake) {
this.objBox.scrollTop = this.objBox.scrollTop+20;
nextCall=true;
} else if (Y-20 < TopLeftY && !this._realfake) {
this.objBox.scrollTop = this.objBox.scrollTop-20;
nextCall=true;
}
this._selectionArea = this._RedrawSelectionPos(this._startSelectionCell, this._endSelectionCell);
if (nextCall){
var a=event.clientX;
var b=event.clientY;
this._blsTimer=window.setTimeout(function(){self._OnSelectionMove({clientX:a,clientY:b})},100);
}
}
dhtmlXGridObject.prototype._OnSelectionStop = function(event)
{
var self = this;
if (this._blsTimer) window.clearTimeout(this._blsTimer);
this.obj.onmousedown = function(e) {if (self._bs_mode) self._OnSelectionStart((e||event), this); return true;}
this.obj.onmousemove = this.obj.onmmold||null;
this._selectionObj.onmousemove = null;
document.body.onmouseup = this._oldDMP||null;
if ( parseInt( this._selectionObj.style.width ) < 2 && parseInt( this._selectionObj.style.height ) < 2) {
this._HideSelection();
} else {
var src = this.getFirstParentOfType(event.srcElement || event.target,"TD");
if ((!src) || (!src.parentNode.idd)){
src=this._endSelectionCell;
}
while (src && (!src.tagName || src.tagName.toLowerCase() != 'td'))
src = src.parentNode;
if (!src) return this._HideSelection();
this._stopSelectionCell = src;
this._selectionArea = this._RedrawSelectionPos(this._startSelectionCell, this._stopSelectionCell);
this.callEvent("onBlockSelected",[]);
}
document.body.onselectstart = function(){};//avoid text select
}
dhtmlXGridObject.prototype._RedrawSelectionPos = function(LeftTop, RightBottom)
{
// td._cellIndex
//
// getRowIndex
var pos = {};
pos.LeftTopCol = LeftTop._cellIndex;
pos.LeftTopRow = this.getRowIndex( LeftTop.parentNode.idd );
pos.RightBottomCol = RightBottom._cellIndex;
pos.RightBottomRow = this.getRowIndex( RightBottom.parentNode.idd );
var LeftTop_width = LeftTop.offsetWidth;
var LeftTop_height = LeftTop.offsetHeight;
LeftTop = this.getPosition(LeftTop, this.obj);
var RightBottom_width = RightBottom.offsetWidth;
var RightBottom_height = RightBottom.offsetHeight;
RightBottom = this.getPosition(RightBottom, this.obj);
if (LeftTop[0] < RightBottom[0]) {
var Left = LeftTop[0];
var Right = RightBottom[0] + RightBottom_width;
} else {
var foo = pos.RightBottomCol;
pos.RightBottomCol = pos.LeftTopCol;
pos.LeftTopCol = foo;
var Left = RightBottom[0];
var Right = LeftTop[0] + LeftTop_width;
}
if (LeftTop[1] < RightBottom[1]) {
var Top = LeftTop[1];
var Bottom = RightBottom[1] + RightBottom_height;
} else {
var foo = pos.RightBottomRow;
pos.RightBottomRow = pos.LeftTopRow;
pos.LeftTopRow = foo;
var Top = RightBottom[1];
var Bottom = LeftTop[1] + LeftTop_height;
}
var Width = Right - Left;
var Height = Bottom - Top;
this._selectionObj.style.left = Left + 'px';
this._selectionObj.style.top = Top + 'px';
this._selectionObj.style.width = Width + 'px';
this._selectionObj.style.height = Height + 'px';
return pos;
}
dhtmlXGridObject.prototype._CreateSelection = function(x, y)
{
if (this._selectionObj == null) {
var div = document.createElement('div');
div.style.position = 'absolute';
div.style.display = 'none';
div.className = 'dhtmlxGrid_selection';
this._selectionObj = div;
this._selectionObj.onmousedown = function(e){
e=e||event;
if (e.button==2 || (_isMacOS&&e.ctrlKey))
return this.parentNode.grid.callEvent("onBlockRightClick", ["BLOCK",e]);
}
this._selectionObj.oncontextmenu=function(e){(e||event).cancelBubble=true;return false;}
this.objBox.appendChild(this._selectionObj);
}
//this._selectionObj.style.border = '1px solid #83abeb';
this._selectionObj.style.width = '0px';
this._selectionObj.style.height = '0px';
//this._selectionObj.style.border = '0px';
this._selectionObj.style.left = x + 'px';
this._selectionObj.style.top = y + 'px';
this._selectionObj.startX = x;
this._selectionObj.startY = y;
}
dhtmlXGridObject.prototype._ShowSelection = function()
{
if (this._selectionObj)
this._selectionObj.style.display = '';
}
dhtmlXGridObject.prototype._HideSelection = function()
{
if (this._selectionObj)
this._selectionObj.style.display = 'none';
this._selectionArea = null;
this._clip_area.value="";
this._clip_area.blur();
}
/**
* @desc: copy content of block selection into clipboard in csv format (delimiter as set for csv serialization)
* @type: public
* @topic: 0
*/
dhtmlXGridObject.prototype.copyBlockToClipboard = function()
{
if ( this._selectionArea != null ) {
var serialized = new Array();
if (this._mathSerialization)
this._agetm="getMathValue";
else if (this._strictText)
this._agetm="getTitle";
else this._agetm="getValue";
this._serialize_visible = true;
for (var i=this._selectionArea.LeftTopRow; i<=this._selectionArea.RightBottomRow; i++) {
var data = this._serializeRowToCVS(this.rowsBuffer[i], null, this._selectionArea.LeftTopCol, this._selectionArea.RightBottomCol+1);
if (!this._csvAID)
serialized[serialized.length] = data.substr( data.indexOf( this.csv.cell ) + 1 ); //remove row ID and add to array
else
serialized[serialized.length] = data;
}
serialized = serialized.join(this._CSVRowDelimiter);
this._clip_area.value = serialized;
this._clip_area.select();
this._serialize_visible = false;
}
}
/**
* @desc: paste content of clipboard into block selection of grid
* @type: public
* @topic: 0
*/
dhtmlXGridObject.prototype.pasteBlockFromClipboard = function(){
this._clip_area.select();
var self = this;
window.setTimeout(function(){
self._pasteBlockFromClipboard();
self=null;
},1);
}
dhtmlXGridObject.prototype._pasteBlockFromClipboard = function()
{
var serialized = this._clip_area.value;
if (this._selectionArea != null) {
var startRow = this._selectionArea.LeftTopRow;
var startCol = this._selectionArea.LeftTopCol;
} else if (this.cell != null && !this.editor) {
var startRow = this.getRowIndex( this.cell.parentNode.idd );
var startCol = this.cell._cellIndex;
} else {
return false;
}
serialized = this.csvParser.unblock(serialized, this.csv.cell, this.csv.row);
// if ((serialized.length >1)&&(serialized[serialized.length-1]==""))
// serialized.splice(serialized.length-1,1);
// if (serialized[serialized.length-1]=="") serialized.pop();
/* for (var i=0; i<serialized.length; i++) {
serialized[i] = serialized[i].split(this.csv.cell);
}*/
var endRow = startRow+serialized.length;
var endCol = startCol+serialized[0].length;
if (endCol > this._cCount)
endCol = this._cCount;
var k = 0;
for (var i=startRow; i<endRow; i++) {
var row = this.render_row(i);
if (row==-1) continue;
var l = 0;
for (var j=startCol; j<endCol; j++) {
if (this._hrrar[j]){
endCol = Math.max(endCol+1, this._cCount);
continue;
}
var ed = this.cells3(row, j);
if (ed.isDisabled()) {
l++;
continue;
}
if (this._onEditUndoRedo)
this._onEditUndoRedo(2, row.idd, j, serialized[ k ][ l ], ed.getValue());
if (ed.combo){
var comboVa = ed.combo.values;
for(var n=0; n<comboVa.length; n++)
if (serialized[ k ][ l ] == comboVa[n]){
ed.setValue( ed.combo.keys[ n ]);
comboVa=null;
break;
}
if (comboVa!=null && ed.editable) ed.setValue( serialized[ k ][ l++ ] );
else l++;
}else
ed[ ed.setImage ? "setLabel" : "setValue" ]( serialized[ k ][ l++ ] );
ed.cell.wasChanged=true;
}
this.callEvent("onRowPaste",[row.idd])
k++;
}
}
dhtmlXGridObject.prototype.getSelectedBlock = function() {
// if block selection exists
if (this._selectionArea)
return this._selectionArea;
else if (this.getSelectedRowId() !== null){
// if one cell is selected
return {
LeftTopRow: this.getSelectedRowId(),
LeftTopCol: this.getSelectedCellIndex(),
RightBottomRow: this.getSelectedRowId(),
RightBottomCol: this.getSelectedCellIndex()
};
} else
return null;
};
//(c)dhtmlx ltd. www.dhtmlx.com

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,204 @@
/*
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: enable smart rendering mode
* @type: public
* @param: mode - true|false - enable|disable mode
* @param: buffer - has sense only in dynamic loading mode, count of rows requrested from server by single operation, optional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableSmartRendering=function(mode,buffer,reserved){
if (arguments.length>2){
if (buffer && !this.rowsBuffer[buffer-1]) this.rowsBuffer[buffer-1]=0;
buffer=reserved;
}
this._srnd=convertStringToBoolean(mode);
this._srdh=this._srdh||20;
this._dpref=buffer||0;
};
/**
* @desc: allows to pre-render rows during scrolling, make scrolling more smooth, but with small drop in overall perfomance
* @type: public
* @param: buffer - count of rows, which will be prerendered
* @topic: 0
*/
dhtmlXGridObject.prototype.enablePreRendering=function(buffer){
this._srnd_pr=parseInt(buffer||50);
};
/**
* @desc: force grid in dyn. srnd mode fully load itself from server side
* @type: public
* @param: buffer - how much rows grid can request from server side in one operation
* @topic: 0
*/
dhtmlXGridObject.prototype.forceFullLoading=function(buffer, callback){
for (var i=0; i<this.rowsBuffer.length; i++)
if (!this.rowsBuffer[i]){
var usedbuffer = buffer || (this.rowsBuffer.length-i);
if (this.callEvent("onDynXLS",[i,usedbuffer])){
var self=this;
this.load(this.xmlFileUrl+getUrlSymbol(this.xmlFileUrl)+"posStart="+i+"&count="+usedbuffer, function(){
window.setTimeout(function(){ self.forceFullLoading(buffer, callback); },100);
}, this._data_type);
}
return;
}
if (callback) callback.call(this);
};
/**
* @desc: set height which will be used in smart rendering mode for row calculation, function need to be used if you use custom skin for grid which changes default row height
* @type: public
@param: {int} height - awaited height of row
* @returns: void
* @topic: 0
*/
dhtmlXGridObject.prototype.setAwaitedRowHeight = function(height) {
this._srdh=parseInt(height);
};
dhtmlXGridObject.prototype._get_view_size=function(){
return Math.floor(parseInt(this.entBox.offsetHeight)/this._srdh)+2;
};
dhtmlXGridObject.prototype._add_filler=function(pos,len,fil,rsflag){
if (!len) return null;
var id="__filler__";
var row=this._prepareRow(id);
row.firstChild.style.width="1px";
for (var i=1; i<row.childNodes.length; i++)
row.childNodes[i].style.display='none';
row.firstChild.style.height=len*this._srdh+"px";
fil=fil||this.rowsCol[pos];
if (fil && fil.nextSibling)
fil.parentNode.insertBefore(row,fil.nextSibling);
else
if (_isKHTML)
this.obj.appendChild(row);
else
this.obj.rows[0].parentNode.appendChild(row);
this.callEvent("onAddFiller",[pos,len,row,fil,rsflag]);
return [pos,len,row];
};
dhtmlXGridObject.prototype._update_srnd_view=function(){
var min=Math.floor(this.objBox.scrollTop/this._srdh);
var max=min+this._get_view_size();
if (this.multiLine) {
// Calculate the min, by Stephane Bernard
var pxHeight = this.objBox.scrollTop;
min = 0;
while(pxHeight > 0) {
pxHeight-=this.rowsCol[min]?this.rowsCol[min].offsetHeight:this._srdh;
min++;
}
// Calculate the max
max=min+this._get_view_size();
if (min>0) min--;
}
max+=(this._srnd_pr||0);//pre-rendering
if (max>this.rowsBuffer.length) max=this.rowsBuffer.length;
for (var j=min; j<max; j++){
if (!this.rowsCol[j]){
var res=this._add_from_buffer(j);
if (res==-1){
if (this.xmlFileUrl){
if (this._dpref && this.rowsBuffer[max-1]){
//we have last row in sett, assuming that we in scrolling up process
var rows_count = this._dpref?this._dpref:(max-j)
var start_pos = Math.max(0, Math.min(j, max - this._dpref));
this._current_load=[start_pos, max-start_pos];
} else
this._current_load=[j,(this._dpref?this._dpref:(max-j))];
if (this.callEvent("onDynXLS",this._current_load))
this.load(this.xmlFileUrl+getUrlSymbol(this.xmlFileUrl)+"posStart="+this._current_load[0]+"&count="+this._current_load[1], this._data_type);
}
return;
} else {
if (this._tgle){
this._updateLine(this._h2.get[this.rowsBuffer[j].idd],this.rowsBuffer[j]);
this._updateParentLine(this._h2.get[this.rowsBuffer[j].idd],this.rowsBuffer[j]);
}
if (j && j==(this._realfake?this._fake:this)["_r_select"]){
this.selectCell(j, this.cell?this.cell._cellIndex:0, true);
}
}
}
}
if (this._fake && !this._realfake && this.multiLine)
this._fake.objBox.scrollTop = this.objBox.scrollTop;
}
dhtmlXGridObject.prototype._add_from_buffer=function(ind){
var row=this.render_row(ind);
if (row==-1) return -1;
if (row._attrs["selected"] || row._attrs["select"]){
this.selectRow(row,false,true);
row._attrs["selected"]=row._attrs["select"]=null;
}
if (!this._cssSP){
if (this._cssEven && ind%2 == 0 )
row.className=this._cssEven+((row.className.indexOf("rowselected") != -1)?" rowselected ":" ")+(row._css||"");
else if (this._cssUnEven && ind%2 == 1 )
row.className=this._cssUnEven+((row.className.indexOf("rowselected") != -1)?" rowselected ":" ")+(row._css||"");
} else if (this._h2) {
var x=this._h2.get[row.idd];
row.className+=" "+((x.level%2)?(this._cssUnEven+" "+this._cssUnEven):(this._cssEven+" "+this._cssEven))+"_"+x.level+(this.rowsAr[x.id]._css||"");
}
//now we need to get location of node
for (var i=0; i<this._fillers.length; i++){
var f=this._fillers[i];
if (f && f[0]<=ind && (f[0]+f[1])>ind ){
//filler found
var pos=ind-f[0];
if (pos==0){
//start
this._insert_before(ind,row,f[2]);
this._update_fillers(i,-1,1);
} else if (pos == f[1]-1){
this._insert_after(ind,row,f[2]);
this._update_fillers(i,-1,0);
} else {
this._fillers.push(this._add_filler(ind+1,f[1]-pos-1,f[2],1));
this._insert_after(ind,row,f[2]);
this._update_fillers(i,-f[1]+pos,0);
}
return;
}
}
}
dhtmlXGridObject.prototype._update_fillers=function(ind,right,left){
var f=this._fillers[ind];
f[1]=f[1]+right;
f[0]=f[0]+left;
if (!f[1]){
this.callEvent("onRemoveFiller",[f[2]]);
f[2].parentNode.removeChild(f[2]);
this._fillers.splice(ind,1);
} else {
f[2].firstChild.style.height=parseFloat(f[2].firstChild.style.height)+right*this._srdh+"px";
this.callEvent("onUpdateFiller",[f[2]]);
}
}
dhtmlXGridObject.prototype._insert_before=function(ind,row,fil){
fil.parentNode.insertBefore(row,fil);
this.rowsCol[ind]=row;
this.callEvent("onRowInserted",[row,null,fil,"before"]);
}
dhtmlXGridObject.prototype._insert_after=function(ind,row,fil){
if (fil.nextSibling)
fil.parentNode.insertBefore(row,fil.nextSibling);
else
fil.parentNode.appendChild(row);
this.rowsCol[ind]=row;
this.callEvent("onRowInserted",[row,null,fil,"after"]);
}

View File

@ -0,0 +1,324 @@
/*
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: enable automatic size saving to cookie
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableAutoSizeSaving = function(name,cookie_param){
this.attachEvent("onResizeEnd",function(){ this.saveSizeToCookie(name,cookie_param) });
}
/**
* @desc: store opene state of TreeGrid in cookie
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.saveOpenStates = function(name,cookie_param){
if (!name) name=this.entBox.id;
var t=[];
this._h2.forEachChild(0,function(el){
if (el.state=="minus") t.push(el.id);
});
var str = "gridOpen"+(name||"") + "=" + t.join("|") + (cookie_param?("; "+cookie_param):"");
document.cookie = str;
}
/**
* @desc: load open state of TreeGrid in cookie
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.loadOpenStates = function(name,cookie_param){
var val=this.getCookie(name,"gridOpen");
if (!val) return;
val=val.split("|");
for (var i = 0; i < val.length; i++) {
var pid = this.getParentId(val[i]);
if (!this.getOpenState(pid)) continue;
this.openItem(val[i]);
}
}
/**
* @desc: enable automatic saving column state ( hidden | shown )
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableAutoHiddenColumnsSaving = function(name,cookie_param){
this.attachEvent("onColumnHidden",function(){
this.saveHiddenColumnsToCookie(name,cookie_param);
});
}
/**
* @desc: enable automatic sorting state saving to cookie
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableSortingSaving = function(name,cookie_param){
this.attachEvent("onBeforeSorting",function(){
var that=this;
window.setTimeout(function(){
that.saveSortingToCookie(name,cookie_param);
},1);
return true;
});
}
/**
* @desc: enable automatic column order saving to cookie
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableOrderSaving = function(name,cookie_param){
this.attachEvent("onAfterCMove",function(){
this.saveOrderToCookie(name,cookie_param);
this.saveSizeToCookie(name,cookie_param);
});
}
/**
* @desc: enable automatic saving of all possible params
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @type: public
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.enableAutoSaving = function(name,cookie_param){
this.enableOrderSaving(name,cookie_param);
this.enableAutoSizeSaving(name,cookie_param);
this.enableSortingSaving(name,cookie_param);
}
/** @desc: save grid layout to cookie
* @type: public
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.saveSizeToCookie=function(name,cookie_param){
if (this.cellWidthType=='px')
var z=this.cellWidthPX.join(",");
else
var z=this.cellWidthPC.join(",");
var z2=(this.initCellWidth||(new Array)).join(",");
this.setCookie(name,cookie_param,0,z);
this.setCookie(name,cookie_param,1,z2);
}
/** @desc: save hidden columns to cookie
* @type: public
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.saveHiddenColumnsToCookie=function(name,cookie_param){
var hs=[].concat(this._hrrar||[]);
if (this._fake && this._fake._hrrar)
for (var i=0; i < this._fake._cCount; i++)
hs[i]=this._fake._hrrar[i]?"1":"";
this.setCookie(name,cookie_param,4,hs.join(",").replace(/display:none;/g,"1"));
}
/** @desc: load sorting order from cookie
* @type: public
* @param: name - optional,cookie name
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.loadHiddenColumnsFromCookie=function(name){
var z=this._getCookie(name,4);
var ar=(z||"").split(",");
for (var i=0; i < this._cCount; i++)
this.setColumnHidden(i,(ar[i]?true:false));
}
/** @desc: save sorting order to cookie
* @type: public
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.saveSortingToCookie=function(name,cookie_param){
this.setCookie(name,cookie_param,2,(this.getSortingState()||[]).join(","));
}
/** @desc: load sorting order from cookie
* @type: public
* @param: name - optional,cookie name
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.loadSortingFromCookie=function(name){
var z=this._getCookie(name,2);
z=(z||"").split(",");
if (z.length>1 && z[0]<this._cCount){
this.sortRows(z[0],null,z[1]);
this.setSortImgState(true,z[0],z[1]);
}
}
/** @desc: save sorting order to cookie
* @type: public
* @param: name - optional, cookie name
* @param: cookie_param - additional parameters added to cookie
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.saveOrderToCookie=function(name,cookie_param){
if (!this._c_order) {
this._c_order=[];
var l=this._cCount;
for (var i=0; i<l; i++)
this._c_order[i]=i;
}
this.setCookie(name,cookie_param,3,((this._c_order||[]).slice(0,this._cCount)).join(","));
this.saveSortingToCookie();
}
/** @desc: load sorting order from cookie
* @type: public
* @param: name - optional,cookie name
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.loadOrderFromCookie=function(name){
var z=this._getCookie(name,3);
z=(z||"").split(",");
if (z.length>1 && z.length<=this._cCount){
//code below probably may be optimized
for (var i=0; i<z.length; i++)
if ((!this._c_order && z[i]!=i)||(this._c_order && z[i]!=this._c_order[i])){
var t=z[i];
if (this._c_order)
for (var j=0; j<this._c_order.length; j++) {
if (this._c_order[j]==z[i]) {
t=j; break;
}
}
this.moveColumn(t*1,i);
}
}
}
/** @desc: load grid layout from cookie
* @type: public
* @param: name - optional,cookie name
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.loadSizeFromCookie=function(name){
var z=this._getCookie(name,1);
if (z)
this.initCellWidth=z.split(",");
var z=this._getCookie(name,0);
if ((z)&&(z.length)){
if (!this._fake && this._hrrar)
for (var i=0; i<z.length; i++)
if ( this._hrrar[i]) z[i]=0;
if (this.cellWidthType=='px')
this.cellWidthPX=z.split(",");
else
this.cellWidthPC=z.split(",");
}
this.setSizes();
return true;
}
/** @desc: clear cookie with grid config details
* @type: public
* @param: name - optional,cookie name
* @edition: Professional
* @topic: 2
*/
dhtmlXGridObject.prototype.clearConfigCookie=function(name){
if (!name) name=this.entBox.id;
var str = "gridSettings"+name + "=||||";
document.cookie = str;
}
dhtmlXGridObject.prototype.clearSizeCookie=dhtmlXGridObject.prototype.clearConfigCookie;
/** @desc: save cookie
* @type: private
* @param: name - cookie name
* @param: value - cookie value
* @param: cookie_param - additional parameters added to cookie
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.setCookie=function(name,cookie_param,pos,value) {
if (!name) name=this.entBox.id;
var t=this.getCookie(name);
t=(t||"||||").split("|");
t[pos]=value;
var str = "gridSettings"+name + "=" + t.join("|").replace(/,/g,"-") + (cookie_param?("; "+cookie_param):"");
// console.log("save",str)
document.cookie = str;
}
/** @desc: get cookie
* @type: private
* @param: name - cookie name
* @edition: Professional
* @topic: 0
*/
dhtmlXGridObject.prototype.getCookie=function(name,surname) {
if (!name) name=this.entBox.id;
name=(surname||"gridSettings")+name;
var search = name + "=";
if (document.cookie.length > 0) {
var offset = document.cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
var end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
return document.cookie.substring(offset, end);
} }
};
dhtmlXGridObject.prototype._getCookie=function(name,pos) {
// console.log("get",this.getCookie(name))
return ((this.getCookie(name)||"||||").replace(/-/g,",").split("|"))[pos];
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,167 @@
/*
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
*/
function dhtmlXGridFromTable(obj,init){
if(typeof(obj)!='object')
obj = document.getElementById(obj);
var w=document.createElement("DIV");
w.setAttribute("width",obj.getAttribute("gridWidth")||(obj.offsetWidth?(obj.offsetWidth+"px"):0)||(window.getComputedStyle?window.getComputedStyle(obj,null)["width"]:(obj.currentStyle?obj.currentStyle["width"]:0)));
w.setAttribute("height",obj.getAttribute("gridHeight")||(obj.offsetHeight?(obj.offsetHeight+"px"):0)||(window.getComputedStyle?window.getComputedStyle(obj,null)["height"]:(obj.currentStyle?obj.currentStyle["height"]:0)));
w.className = obj.className;
obj.className="";
if (obj.id) w.id = obj.id;
var mr=obj;
var drag=obj.getAttribute("dragAndDrop");
mr.parentNode.insertBefore(w,mr);
var f=mr.getAttribute("name")||("name_"+(new Date()).valueOf());
var windowf=new dhtmlXGridObject(w);
window[f]=windowf;
var acs=mr.getAttribute("onbeforeinit");
var acs2=mr.getAttribute("oninit");
if (acs) eval(acs);
windowf.setImagePath(windowf.imgURL||(mr.getAttribute("imgpath")|| mr.getAttribute("image_path") ||""));
var skin = mr.getAttribute("skin");
if (skin) windowf.setSkin(skin);
if (init) init(windowf);
var hrow=mr.rows[0];
var za="";
var zb="";
var zc="";
var zd="";
var ze="";
for (var i=0; i<hrow.cells.length; i++){
za+=(za?",":"")+hrow.cells[i].innerHTML;
var width=hrow.cells[i].getAttribute("width")||hrow.cells[i].offsetWidth||(window.getComputedStyle?window.getComputedStyle(hrow.cells[i],null)["width"]:(hrow.cells[i].currentStyle?hrow.cells[i].currentStyle["width"]:0));
zb+=(zb?",":"")+(width=="*"?width:parseInt(width));
zc+=(zc?",":"")+(hrow.cells[i].getAttribute("align")||"left");
zd+=(zd?",":"")+(hrow.cells[i].getAttribute("type")||"ed");
ze+=(ze?",":"")+(hrow.cells[i].getAttribute("sort")||"str");
var f_a=hrow.cells[i].getAttribute("format");
if (f_a)
if(hrow.cells[i].getAttribute("type").toLowerCase().indexOf("calendar")!=-1)
windowf._dtmask=f_a;
else
windowf.setNumberFormat(f_a,i);
}
windowf.setHeader(za);
windowf.setInitWidths(zb)
windowf.setColAlign(zc)
windowf.setColTypes(zd);
windowf.setColSorting(ze);
if (obj.getAttribute("gridHeight")=="auto")
windowf.enableAutoHeigth(true);
if (obj.getAttribute("multiline")) windowf.enableMultiline(true);
var lmn=mr.getAttribute("lightnavigation");
if (lmn) windowf.enableLightMouseNavigation(lmn);
var evr=mr.getAttribute("evenrow");
var uevr=mr.getAttribute("unevenrow");
if (evr||uevr) windowf.enableAlterCss(evr,uevr);
if (drag) windowf.enableDragAndDrop(true);
windowf.init();
if (obj.getAttribute("split")) windowf.splitAt(obj.getAttribute("split"));
//adding rows
windowf._process_inner_html(mr,1);
if (acs2) eval(acs2);
if (obj.parentNode && obj.parentNode.removeChild)
obj.parentNode.removeChild(obj);
return windowf;
}
dhtmlXGridObject.prototype._process_html=function(xml){
if (xml.tagName && xml.tagName == "TABLE") return this._process_inner_html(xml,0);
var temp=document.createElement("DIV");
temp.innerHTML=xml.xmlDoc.responseText;
var mr = temp.getElementsByTagName("TABLE")[0];
this._process_inner_html(mr,0);
}
dhtmlXGridObject.prototype._process_inner_html=function(mr,start){
var n_l=mr.rows.length;
for (var j=start; j<n_l; j++){
var id=mr.rows[j].getAttribute("id")||j;
this.rowsBuffer.push({ idd:id, data:mr.rows[j], _parser: this._process_html_row, _locator:this._get_html_data });
}
this.render_dataset();
this.setSizes();
}
dhtmlXGridObject.prototype._process_html_row=function(r,xml){
var cellsCol = xml.getElementsByTagName('TD');
var strAr = [];
r._attrs=this._xml_attrs(xml);
//load cell data
for(var j=0;j<cellsCol.length;j++){
var cellVal=cellsCol[j];
var exc=cellVal.getAttribute("type");
if (r.childNodes[j]){
if (exc)
r.childNodes[j]._cellType=exc;
r.childNodes[j]._attrs=this._xml_attrs(cellsCol[j]);
}
if (cellVal.firstChild)
strAr.push(cellVal.innerHTML);
else strAr.push("");
if (cellVal.colSpan>1){
r.childNodes[j]._attrs["colspan"]=cellVal.colSpan;
for (var k=1; k<cellVal.colSpan; k++){
strAr.push("")
}
}
}
for(j<cellsCol.length; j<r.childNodes.length; j++)
r.childNodes[j]._attrs={};
//back to common code
this._fillRow(r,(this._c_order?this._swapColumns(strAr):strAr));
return r;
}
dhtmlXGridObject.prototype._get_html_data=function(data,ind){
data=data.firstChild;
while (true){
if (!data) return "";
if (data.tagName=="TD") ind--;
if (ind<0) break;
data=data.nextSibling;
}
return (data.firstChild?data.firstChild.data:"");
}
dhtmlxEvent(window,"load",function(){
var z=document.getElementsByTagName("table");
for (var a=0; a<z.length; a++)
if (z[a].className=="dhtmlxGrid"){
dhtmlXGridFromTable(z[a]);
//we have found IT!
}
});
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,110 @@
/*
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: enable Undo/Redo functionality in grid
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.enableUndoRedo = function()
{
var self = this;
var func = function() {return self._onEditUndoRedo.apply(self,arguments);}
this.attachEvent("onEditCell", func);
var func2 = function(a,b,c) {return self._onEditUndoRedo.apply(self,[2,a,b,(c?1:0),(c?0:1)]);}
this.attachEvent("onCheckbox", func2);
this._IsUndoRedoEnabled = true;
this._UndoRedoData = [];
this._UndoRedoPos = -1;
}
/**
* @desc: disable Undo/Redo functionality in grid
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.disableUndoRedo = function()
{
this._IsUndoRedoEnabled = false;
this._UndoRedoData = [];
this._UndoRedoPos = -1;
}
dhtmlXGridObject.prototype._onEditUndoRedo = function(stage, row_id, cell_index, new_value, old_value)
{
if (this._IsUndoRedoEnabled && stage == 2 && old_value != new_value) {
if (this._UndoRedoPos !== -1 && this._UndoRedoPos != ( this._UndoRedoData.length-1 ) ) {
this._UndoRedoData = this._UndoRedoData.slice(0, this._UndoRedoPos+1);
} else if (this._UndoRedoPos === -1 && this._UndoRedoData.length > 0) {
this._UndoRedoData = [];
}
var obj = { old_value:old_value,
new_value:new_value,
row_id:row_id,
cell_index:cell_index
};
this._UndoRedoData.push(obj);
this._UndoRedoPos++;
}
return true;
}
/**
* @desc: UnDo
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.doUndo = function()
{
if (this._UndoRedoPos === -1)
return false;
var obj = this._UndoRedoData[this._UndoRedoPos--];
var c=this.cells(obj.row_id, obj.cell_index);
if (this.getColType(obj.cell_index)=="tree")
c.setLabel(obj.old_value);
else
c.setValue(obj.old_value);
this.callEvent("onUndo", [obj.row_id]);
}
/**
* @desc: ReDo
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.doRedo = function()
{
if (this._UndoRedoPos == this._UndoRedoData.length-1)
return false;
var obj = this._UndoRedoData[++this._UndoRedoPos];
this.cells(obj.row_id, obj.cell_index).setValue(obj.new_value);
this.callEvent("onUndo", [obj.row_id]);
}
/**
* @desc: get length of available ReDo operations
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.getRedo = function()
{
if (this._UndoRedoPos == this._UndoRedoData.length-1)
return [];
return this._UndoRedoData.slice(this._UndoRedoPos+1);
}
/**
* @desc: get length of available UnDo operations
* @type: public
* @edition: Professional
*/
dhtmlXGridObject.prototype.getUndo = function()
{
if (this._UndoRedoPos == -1)
return [];
return this._UndoRedoData.slice(0, this._UndoRedoPos+1);
}
//(c)dhtmlx ltd. www.dhtmlx.com

View File

@ -0,0 +1,168 @@
/*
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
*/
//all purpose set of rules, based on http://code.google.com/p/validation-js
dhtmlxValidation=function(){};
dhtmlxValidation.prototype={
trackInput:function(el,rule,callback_error,callback_correct){
dhtmlxEvent(el,"keyup",function(e){
if (dhtmlxValidation._timer) {
window.clearTimeout(dhtmlxValidation._timer);
dhtmlxValidation._timer = null;
}
dhtmlxValidation._timer = window.setTimeout(function(){
if (!dhtmlxValidation.checkInput(el,rule)){
if(!callback_error || callback_error(el,el.value,rule))
el.className+=" dhtmlx_live_validation_error";
} else {
el.className=el.className.replace(/[ ]*dhtmlx_live_validation_error/g,"");
if (callback_correct)
callback_correct(el,el.value,rule);
}
},250);
});
},
checkInput:function(input,rule){
return this.checkValue(input.value,rule);
},
checkValue:function(value,rule){
if (typeof rule=="string")
rule = rule.split(",");
var final_res=true;
for (var i=0; i<rule.length; i++){
if (!this["is"+rule[i]])
alert("Incorrect validation rule: "+rule[i]);
else
final_res=final_res&&this["is"+rule[i]](value);;
}
return final_res;
},
isEmpty: function(value) {
return value == '';
},
isNotEmpty: function(value) {
return (value instanceof Array?value.length>0:!value == ''); // array in case of multiselect
},
isValidBoolean: function(value) {
return !!value.toString().match(/^(0|1|true|false)$/);
},
isValidEmail: function(value) {
return !!value.toString().match(/(^[a-z0-9]([0-9a-z\-_\.]*)@([0-9a-z_\-\.]*)([.][a-z]{3})$)|(^[a-z]([0-9a-z_\.\-]*)@([0-9a-z_\-\.]*)(\.[a-z]{2,4})$)/i);
},
isValidInteger: function(value) {
return !!value.toString().match(/(^-?\d+$)/);
},
isValidNumeric: function(value) {
return !!value.toString().match(/(^-?\d\d*[\.|,]\d*$)|(^-?\d\d*$)|(^-?[\.|,]\d\d*$)/);
},
isValidAplhaNumeric: function(value) {
return !!value.toString().match(/^[_\-a-z0-9]+$/gi);
},
// 0000-00-00 00:00:00 to 9999:12:31 59:59:59 (no it is not a "valid DATE" function)
isValidDatetime: function(value) {
var dt = value.toString().match(/^(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})$/);
return dt && !!(dt[1]<=9999 && dt[2]<=12 && dt[3]<=31 && dt[4]<=59 && dt[5]<=59 && dt[6]<=59) || false;
},
// 0000-00-00 to 9999-12-31
isValidDate: function(value) {
var d = value.toString().match(/^(\d{4})-(\d{2})-(\d{2})$/);
return d && !!(d[1]<=9999 && d[2]<=12 && d[3]<=31) || false;
},
// 00:00:00 to 59:59:59
isValidTime: function(value) {
var t = value.toString().match(/^(\d{1,2}):(\d{1,2}):(\d{1,2})$/);
return t && !!(t[1]<=24 && t[2]<=59 && t[3]<=59) || false;
},
// 0.0.0.0 to 255.255.255.255
isValidIPv4: function(value) {
var ip = value.toString().match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
return ip && !!(ip[1]<=255 && ip[2]<=255 && ip[3]<=255 && ip[4]<=255) || false;
},
isValidCurrency: function(value) { // Q: Should I consider those signs valid too ? : ¢|€|₤|₦|¥
return value.toString().match(/^\$?\s?\d+?([\.,\,]?\d+)?\s?\$?$/) && true || false;
},
// Social Security Number (999-99-9999 or 999999999)
isValidSSN: function(value) {
return value.toString().match(/^\d{3}\-?\d{2}\-?\d{4}$/) && true || false;
},
// Social Insurance Number (999999999)
isValidSIN: function(value) {
return value.toString().match(/^\d{9}$/) && true || false;
}
};
dhtmlxValidation=new dhtmlxValidation();
//extension for the grid
dhtmlXGridObject.prototype.enableValidation=function(mode,live){
mode=convertStringToBoolean(mode);
if (mode){
this._validators={ data:[] };
}else
this._validators=false;
if (arguments.length>1)
this._validators._live=live;
if (!this._validators._event)
this._validators._event=this.attachEvent("onEditCell",this.validationEvent);
};
dhtmlXGridObject.prototype.setColValidators=function(vals){
if (!this._validators) this.enableValidation(true);
if (typeof vals == "string") vals=vals.split(this.delim);
this._validators.data=vals;
};
dhtmlXGridObject.prototype.validationEvent=function(stage,id,ind,newval,oldval){
var v=this._validators;
if (!v) return true; // validators disabled
var rule=(v.data[ind]||this.cells(id,ind).getAttribute("validate"))||"";
if (stage==1 && rule){
var ed = this.editor||(this._fake||{}).editor;
if (!ed) return true; //event was trigered by checkbox
ed.cell.className=ed.cell.className.replace(/[ ]*dhtmlx_validation_error/g,"");
if (v._live){
var grid=this;
dhtmlxValidation.trackInput(ed.getInput(),rule,function(element,value,rule){
return grid.callEvent("onLiveValidationError",[id,ind,value,element,rule]);
},function(element,value,rule){
return grid.callEvent("onLiveValidationCorrect",[id,ind,value,element,rule]);
});
}
}
if (stage==2)
this.validateCell(id,ind,rule,newval);
return true;
};
dhtmlXGridObject.prototype.validateCell=function(id,ind,rule,value){
rule=rule||(this._validators.data[ind]||this.cells(id,ind).getAttribute("validate"));
value=value||this.cells(id,ind).getValue();
if (!rule) return;
var cell = this.cells(id,ind).cell;
var result = true;
if (typeof rule == "string")
rule = rule.split(this.delim);
for (var i=0; i < rule.length; i++) {
if (!dhtmlxValidation.checkValue(value,rule[i])){
if (this.callEvent("onValidationError",[id,ind,value,rule[i]]))
cell.className+=" dhtmlx_validation_error";
result = false;
}
}
if (result){
this.callEvent("onValidationCorrect",[id,ind,value,rule]);
cell.className=cell.className.replace(/[ ]*dhtmlx_validation_error/g,"");
}
return result;
};