📄 databindingtest.xml
字号:
<?xml version="1.0"?><Application xmlns:xhtml="http://www.w3.org/1999/xhtml"> <Window caption="Data Binding Example" width="200" height="300"> <Label left="10" top="10" right="10" wrap="true"> This example binds a BiList to a BiDataSet </Label> <Button id="change-button" top="50" left="10" text="Change Data Set"/> <List id="list" left="10" right="10" top="80" bottom="30" dataTextField="CategoryName" dataValueField="Description" onchange="this.getComponentById('result').setText( 'Value: ' + event.getCurrentTarget().getUserValue() )"/> <StatusBar> <StatusBarPanel id="result" left="0" right="30"/> <StatusBarPanel id="pages" width="28" right="0" toolTip="#page-tool-tip"/> </StatusBar> <ToolTip id="page-tool-tip" wrap="true" width="150"> Use <xhtml:strong>1-9</xhtml:strong> to set the <xhtml:strong>dataPageSize</xhtml:strong><xhtml:br/> Use <xhtml:strong>+/-</xhtml:strong> to change the <xhtml:strong>currentDataPage</xhtml:strong> </ToolTip> </Window> <Resources> <Script src="ArrayDataSet.js"/> <Script><![CDATA[function DataBindingTest(){ // define two data sets var ds = new BiXmlDataSet( "datasetdata.xml" ); var ds2 = new ArrayDataSet( [["One", 1], ["Two", 2], ["Three", 3], ["Four", 4], ["Five", 5]] ); var l = application.getComponentById( "list" ); l.setDataSource( ds ); l.dataBind(); // hook up change button var changeButton = application.getComponentById( "change-button" ); changeButton.addEventListener( "action", this.changeDataSet, this ); this._ds = ds; this._ds2 = ds2; application.getWindow().addEventListener( "keydown", this.onKeyDown, this ); this.updatePageStatus();}DataBindingTest.main = function () { new DataBindingTest; };//DataBindingTest.URI = "http://www.bindows.net/services/sql.aspx?q=select * from categories";DataBindingTest.prototype.changeDataSet = function (){ var l = application.getComponentById( "list" ); if ( l.getDataSource() == this._ds ) { l.setDataSource( this._ds2 ); l.setDataTextField( "0" ); l.setDataValueField( "1" ); } else { l.setDataSource( this._ds ); l.setDataTextField( "CategoryName" ); l.setDataValueField( "Description" ); } l.dataBind(); this.updatePageStatus();};DataBindingTest.prototype.onKeyDown = function ( e ){ var l = application.getComponentById( "list" ); var ds = l.getDataSource(); var kc = e.getKeyCode(); switch ( kc ) { case BiKeyboardEvent.NUMPAD_PLUS: case 187: // + case 61: // Moz + l.setCurrentDataPage( l.getCurrentDataPage() + 1 ); e.preventDefault(); break; case BiKeyboardEvent.NUMPAD_MINUS: case 189: // - case 109: // Moz - l.setCurrentDataPage( l.getCurrentDataPage() - 1 ); e.preventDefault(); break; default: if ( kc >= 49 && kc <= 57 ) // 1 - 9 { l.setDataPageSize( kc - 48 ); e.preventDefault(); } } this.updatePageStatus();};DataBindingTest.prototype.updatePageStatus = function (){ var l = application.getComponentById( "list" ); var ds = l.getDataSource(); var pages = application.getComponentById( "pages" ); pages.setText( (l.getCurrentDataPage() + 1 ) + "/" + l.getDataPageCount() );}; ]]></Script> </Resources></Application>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -