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

📄 dhtmlxgrid_nxml.js

📁 WEB表格控件
💻 JS
📖 第 1 页 / 共 2 页
字号:
//v.1.6 build 80603/*Copyright DHTMLX LTD. http://www.dhtmlx.comYou allowed to use this component or parts of it under GPL termsTo use it on other terms or get Professional edition of the component please contact us at sales@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*     @edition: Professional*   @topic: 0*/dhtmlXGridObject.prototype.serializeToCSV = function(){     this.editStop()    if (this._mathSerialization)         this._agetm="getMathValue";    else this._agetm="getValue";    var out=[];    if (this._csvHdr){    	var a=[]; var b=this.hdr.rows[1].cells;    	for (var i=0; i<b.length; i++)			if ((!this._srClmn)||(this._srClmn[i]))				a.push(_isIE?b[i].innerText:b[i].textContent);    	out.push(a.join(this.csv.cell));    }        //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 out.join(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();	r=r||this.render_row(i)        if (!this._csvAID)       out[out.length]=r.idd;	start = start||0;	    end = end||r.childNodes.length;    //cells    var changeFl=false;    var ind=start;        for(var jj=start;ind<end;jj++){    	var real_ind=r.childNodes[jj]._cellIndex;        if ((!this._srClmn)||(this._srClmn[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 out.join(this.csv.cell);}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());}/***   @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";       if (rowId)      out=this._serializeRowToCVS(this.getRowById(rowId));   else      for (var i=0; i<this.selectedRows.length; i++){         if (out) out+=this.csv.row;         out+=this._serializeRowToCVS(this.selectedRows[i]);      }   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;   csv=(csv.split(this.csv.row)[0]).split(this.csv.cell);   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]);	  }}/***   @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=csv.split(this.csv.row);

⌨️ 快捷键说明

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