?? databinding.js
字號:
i=s.indexOf("-");if(i>0)
BiXsTypeConverter._applyTimeZone(d,s.substring(i));};BiXsTypeConverter._decodeIsoTime=function(d,s){var i=s.indexOf("+");if(i<0)
i=s.indexOf("-");if(i>0){var tzs=s.substring(i);s=s.substring(0,i);}
d.setHours(s.substr(0,2));d.setMinutes(s.substr(3,2));d.setSeconds(s.substr(6,2));var msi=s.indexOf(".");if(msi>0)
d.setMilliseconds(parseFloat("0."+s.substr(9))*1000);BiXsTypeConverter._applyTimeZone(d,tzs);};BiXsTypeConverter._applyTimeZone=function(d,s){var tzo=0;var parts=s.split(":");if(parts.length>0)
tzo+=parts[0]*60;if(parts.length>1)
tzo+=(tzo<0?-1:1)*Number(parts[1]);d.setTime(d.getTime()-(tzo+d.getTimezoneOffset())*60000);};function BiXmlDataSet(oSource)
{BiDataSet.call(this);if(typeof oSource=="string"||oSource instanceof BiUri)
this.setUri(oSource);else if(typeof oSource=="object")
{this._uri=null;this.fromXmlNode(oSource);this._dataReady=true;}}
_p=BiXmlDataSet.prototype=new BiDataSet;_p._className="BiXmlDataSet";_p._uri=null;_p._rootNode=null;BiXmlDataSet.encodeName=function(s){return s.replace(/(^\d)|(_x)|[\s\W]/gi,BiXmlDataSet._encodeName);};BiXmlDataSet._encodeName=function(s){if(s=="_x"||s=="_X")
return"_x005F"+s;var cc=s.charCodeAt(0);var s2="";if(cc<0x10)
s2="000";else if(cc<0x100)
s2="00";else if(cc<0x1000)
s2="0";return"_x"+s2+cc.toString(16).toUpperCase()+"_";};BiXmlDataSet.decodeName=function(s){return s.replace(/_x([0-9a-f]+)_/gi,BiXmlDataSet._decodeName);};BiXmlDataSet._decodeName=function(s0,s1){return String.fromCharCode(parseInt(s1,16));};_p.setUri=function(oUri)
{if(this._xmlLoader)
this._xmlLoader.dispose();if(oUri instanceof BiUri)
this._uri=oUri;else this._uri=new BiUri(application.getAdfPath(),oUri);this._dataReady=false;this._xmlLoader=new BiXmlLoader;this._xmlLoader.setAsync(true);this._xmlLoader.addEventListener("load",this._onXmlLoad,this);this._xmlLoader.load(this._uri);};BiXmlDataSet.prototype.getUri=function(){return this._uri;};_p.setRootNode=function(oNode)
{this.fromNone(oNode);};BiXmlDataSet.prototype.getRootNode=function(){return this._rootNode;};_p.fromXmlNode=function(oNode){for(var i=this._tables.length-1;i>=0;i--){this._tables[i].dispose();this._tables[i]=null;}
this._tables=[];this._rootNode=oNode;var xp=this.getDataSetNamePath();var schemaRoot=oNode.getElementsByTagName("schema")[0]||oNode.getElementsByTagName("xs:schema")[0];var nl=schemaRoot.selectSingleNode(xp);var s;if(nl)
s=nl.text;else if(this._rootNode.nodeType==9)
s=this._rootNode.documentElement.tagName;else s=this._rootNode.tagName;this._encodedName=s;this._name=BiXmlDataSet.decodeName(s);var xp=this.getTableNamesPath(this._encodedName);var nl=schemaRoot.selectNodes(xp);var l=nl.length;var t;for(var i=0;i<l;i++){t=this._tables[i]=new BiXmlDataTable(nl[i].text);t._dataSet=this;this._tablesByName[t.getName().toLowerCase()]=t;t.fromXmlNode(oNode);}};_p._onXmlLoad=function(e){if(this._xmlLoader.getError()){throw new Error("Error loading Xml file for BiXmlDataSet");}
else{this._dataReady=true;this.fromXmlNode(this._xmlLoader.getDocument());this.dispatchEvent(new BiEvent("dataready"));}};BiXmlDataSet.prototype.getRootNode=function(){return this._rootNode;};BiXmlDataSet.prototype.getEncodedName=function(){return this._encodedName;};_p._nodeListToArray=function(nl){var l=nl.length;var res=new Array(l);for(var i=0;i<l;i++)
res[i]=nl[i].text;return res;};_p.getDataSetNamePath=function(){return".//xs:element[@msdata:IsDataSet=\"true\"]/@name";};_p.getTableNamesPath=function(sDataSetXmlName){return".//xs:element[@name=\""+sDataSetXmlName+"\"]/*/*/xs:element/@name";};_p.getColumnNamesPath=function(sTableXmlName){return".//xs:element[@name=\""+sTableXmlName+"\"]//xs:element/@name";};_p.getColumnTypesPath=function(sTableXmlName){return".//xs:element[@name=\""+sTableXmlName+"\"]//xs:element/@type";};_p.getRowsPath=function(sTableXmlName){return".//"+this._encodedName+"/"+sTableXmlName;};_p.dispose=function(){if(this.getDisposed())return;BiDataSet.prototype.dispose.call(this);if(this._xmlLoader){this._xmlLoader.dispose();this._xmlLoader=null;}};function BiXmlDataTable(sEncodedName){this._encodedName=sEncodedName;BiDataTable.call(this,BiXmlDataSet.decodeName(sEncodedName));};_p=BiXmlDataTable.prototype=new BiDataTable;_p._className="BiXmlDataTable";BiXmlDataTable.prototype.getEncodedName=function(){return this._encodedName;};_p.fromXmlNode=function(oNode){for(var i=this._columns.length-1;i>=0;i--){this._columns[i].dispose();this._columns[i]=null;}
this._columns=[];for(var i=this._rows.length-1;i>=0;i--){this._rows[i].dispose();this._rows[i]=null;}
this._rows=[];var ds=this._dataSet;var schemaRoot=oNode.getElementsByTagName("schema")[0]||oNode.getElementsByTagName("xs:schema")[0];var xp=ds.getColumnNamesPath(this._encodedName);var nl=schemaRoot.selectNodes(xp);var l=nl.length;var c;for(var i=0;i<l;i++){c=this._columns[i]=new BiXmlDataColumn(nl[i].text);c._index=i;c._table=this;this._columnsByName[c.getName().toLowerCase()]=c;}
xp=ds.getColumnTypesPath(this._encodedName);nl=schemaRoot.selectNodes(xp);l=nl.length;for(var i=0;i<l;i++){this._columns[i].setXsType(nl[i].text);}
xp=ds.getRowsPath(this._encodedName);nl=oNode.selectNodes(xp);l=nl.length;for(var i=0;i<l;i++){this._rows[i]=new BiXmlDataRow(nl[i]);this._rows[i]._table=this;}};function BiXmlDataColumn(sEncodedName){this._encodedName=sEncodedName;BiDataColumn.call(this,BiXmlDataSet.decodeName(sEncodedName));};_p=BiXmlDataColumn.prototype=new BiDataColumn;_p._className="BiXmlDataColumn";BiXmlDataColumn.prototype.getEncodedName=function(){return this._encodedName;};BiXmlDataColumn.prototype.getXsType=function(){return this._xsType;};_p.setXsType=function(s){this._xsType=s.replace(/^([^:]+:)/,"");this._dataType=BiXsTypeConverter.getJsTypeName(this._xsType);};function BiXmlDataRow(oXmlElement){BiDataRow.call(this);this._xmlElement=oXmlElement;};_p=BiXmlDataRow.prototype=new BiDataRow;_p._className="BiXmlDataRow";_p.getValueByIndex=function(n){var name=this._table.getColumns()[n].getName();return this.getValueByName(name);};_p.getValueByName=function(s){var c=this._table.getColumnByName(s);if(c)
{var n=c.getEncodedName();var node=this._xmlElement.selectSingleNode(n);var v=BiXsTypeConverter.getJsValue(node?node.text:c.getDefaultValue(),c.getXsType());return v;}
return null;};_p.dispose=function(){if(this.getDisposed())return;BiDataRow.prototype.dispose.call(this);this._xmlElement=null;};_p=BiList.prototype;_p._dataSource=null;_p._dataTextField=null;_p._dataUserValueField=null;_p._dataPageSize=null;_p._dataPageCount=1;_p._currentDataPage=0;BiList.prototype.getDataTextField=function(){return this._dataTextField;};BiList.prototype.setDataTextField=function(v){this._dataTextField=v;};BiList.prototype.getDataUserValueField=function(){return this._dataUserValueField;};BiList.prototype.setDataUserValueField=function(v){this._dataUserValueField=v;};BiList.prototype.getDataSource=function(){return this._dataSource;};BiList.prototype.getDataPageSize=function(){return this._dataPageSize;};BiList.prototype.getDataPageCount=function(){return this._dataPageCount;};BiList.prototype.getCurrentDataPage=function(){return this._currentDataPage;};_p.getDataValueField=_p.getDataUserValueField;_p.setDataValueField=_p.setDataUserValueField;_p.setDataSource=function(oDs)
{if(oDs instanceof BiDataSet||oDs instanceof BiDataTable)
this._dataSource=oDs;else throw new Error("Data source format not supported");};_p.dataBind=function()
{var ds=this._dataSource;if(ds instanceof BiDataTable)
ds=this._dataSource.getDataSet();if(ds.getDataReady())
this._populateWithDataSource();else ds.addEventListener("dataready",this._populateWithDataSource,this);};_p._populateWithDataSource=function(){var cs=this.getChildren();var c;for(var i=cs.length-1;i>=0;i--){c=cs[i];this.remove(c);c.dispose();}
var ds=this._dataSource;if(ds instanceof BiDataSet&&ds.getTables().length==0){this._dataPageSize=null;this._dataPageCount=1;this._currentDataPage=0;}
else{if(ds instanceof BiDataSet)
ds=ds.getTables()[0];var cols=ds.getColumns();var rows=ds.getRows();var startIndex=0;var endIndex=rows.length;var dps=this.getDataPageSize();if(dps!=null&&dps>0)
{this._dataPageCount=Math.max(1,Math.ceil(endIndex/dps));startIndex=dps*this._currentDataPage;if(startIndex+dps>endIndex)
startIndex=endIndex-(endIndex%dps||dps);if(startIndex<0)
startIndex=0;endIndex=Math.min(endIndex,startIndex+dps);this._currentDataPage=startIndex/dps;}
for(var y=startIndex;y<endIndex;y++)
this.add(this.createItemFromDataRow(rows[y]));}
this.dispatchEvent(new BiEvent("databind"));};_p.createItemFromDataRow=function(oRow){return new BiListItem(oRow.getValueByName(this._dataTextField),oRow.getValueByName(this._dataUserValueField));};_p.setCurrentDataPage=function(n)
{n=Math.min(Math.max(0,n),this.getDataPageCount()-1);if(this._currentDataPage!=n)
{this._currentDataPage=n;if(this._dataSource&&this._dataSource.getDataReady())
{this._populateWithDataSource();}}};_p.setDataPageSize=function(n)
{if(this._dataPageSize!=n)
{this._dataPageSize=n;if(this._dataSource&&this._dataSource.getDataReady())
{var t=this._dataSource;if(t instanceof BiDataSet)
t=t.getTables()[0];var rows=t.getRows().length;this._dataPageCount=Math.ceil(rows/this._dataPageSize);this._populateWithDataSource();}}};_p=BiComboBox.prototype;_p.setDataSource=BiList.prototype.setDataSource;_p.dataBind=BiList.prototype.dataBind;_p._populateWithDataSource=BiList.prototype._populateWithDataSource;_p.setCurrentDataPage=BiList.prototype.setCurrentDataPage;_p.setDataPageSize=BiList.prototype.setDataPageSize;_p._dataSource=null;_p._dataTextField=null;_p._dataUserValueField=null;_p._dataPageSize=null;_p._dataPageCount=1;_p._currentDataPage=0;BiComboBox.prototype.getDataTextField=function(){return this._dataTextField;};BiComboBox.prototype.setDataTextField=function(v){this._dataTextField=v;};BiComboBox.prototype.getDataUserValueField=function(){return this._dataUserValueField;};BiComboBox.prototype.setDataUserValueField=function(v){this._dataUserValueField=v;};BiComboBox.prototype.getDataSource=function(){return this._dataSource;};BiComboBox.prototype.getDataPageSize=function(){return this._dataPageSize;};BiComboBox.prototype.getDataPageCount=function(){return this._dataPageCount;};BiComboBox.prototype.getCurrentDataPage=function(){return this._currentDataPage;};_p.getDataValueField=_p.getDataUserValueField;_p.setDataValueField=_p.setDataUserValueField;_p.createItemFromDataRow=function(oRow){return new BiComboBoxItem(oRow.getValueByName(this._dataTextField),oRow.getValueByName(this._dataUserValueField));};_p=BiGrid.prototype;_p.setDataSource=BiList.prototype.setDataSource;_p.dataBind=BiList.prototype.dataBind;_p.setCurrentDataPage=BiList.prototype.setCurrentDataPage;_p.setDataPageSize=BiList.prototype.setDataPageSize;_p._dataSource=null;_p._dataPageSize=null;_p._dataPageCount=1;_p._currentDataPage=0;BiGrid.prototype.getDataSource=function(){return this._dataSource;};BiGrid.prototype.getDataPageSize=function(){return this._dataPageSize;};BiGrid.prototype.getDataPageCount=function(){return this._dataPageCount;};BiGrid.prototype.getCurrentDataPage=function(){return this._currentDataPage;};_p._populateWithDataSource=function(e){this.removeAll();this.sort(-1);var ds=this._dataSource;if(ds instanceof BiDataSet&&ds.getTables().length==0){this.setColumnCount(0);this._dataPageSize=null;this._dataPageCount=1;this._currentDataPage=0;}
else{if(ds instanceof BiDataSet)
ds=ds.getTables()[0];var columns=ds.getColumns();var cols=columns.length;this.setColumnCount(cols);var colOrders=new Array(cols);for(var x=0;x<cols;x++)
colOrders[x]=x;this.setColumnOrders(colOrders);var colNames=new Array(cols);for(var x=0;x<cols;x++)
colNames[x]=columns[x].getName();this.setColumnNames(colNames);var sortTypes=new Array(cols);var aligns=new Array(cols);var dt;for(var x=0;x<cols;x++){dt=columns[x].getDataType();sortTypes[x]=dt;aligns[x]=dt=="number"?"right":"left";}
this.setColumnSortTypes(sortTypes);this.setColumnAligns(aligns);var rows=ds.getRows();var startIndex=0;var endIndex=rows.length;var dps=this.getDataPageSize();if(dps!=null&&dps>0)
{this._dataPageCount=Math.max(1,Math.ceil(endIndex/dps));startIndex=dps*this._currentDataPage;if(startIndex+dps>endIndex)
startIndex=endIndex-(endIndex%dps||dps);if(startIndex<0)
startIndex=0;endIndex=Math.min(endIndex,startIndex+dps);this._currentDataPage=startIndex/dps;}
for(var y=startIndex;y<endIndex;y++)
this.addRow(this.createItemFromDataRow(rows[y]));}
this.update();this._headers.layoutAllChildren();this.dispatchEvent(new BiEvent("databind"));};_p.createItemFromDataRow=function(oRow){var cols=oRow.getTable().getColumns().length;var cellData=new Array(cols);for(var x=0;x<cols;x++){cellData[x]=oRow.getValueByIndex(x);}
return new BiGridRow(cellData);};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -