Final DataGrid class development preview

Status: Functional

New features

Spas 3.0 version alpha 5.4 has been released this week, to match with the new documentation. But the version of the DataGrid class contained within this release cannot be used yet for professional works. We are actively working on the alpha 5.5 release which will provide a fully functional version of the DataGrid class.

The following sample application shows some of the improvements that will be available in the next release:

  • scroll bar navigation improvements,
  • fast data completion,
  • resizing improvements,
  • scroll bar block indent capabilities,
  • etc...

Get Adobe Flash player

package {
	
	import org.flashapi.swing.*;
	import org.flashapi.swing.button.RadioButtonGroup;
	import org.flashapi.swing.constants.*;
	import org.flashapi.swing.databinding.*;
	import org.flashapi.swing.event.*;
	import org.flashapi.swing.framework.*;
	
	public class Main extends Application {
	
		UIManager.debugger = new FDTrace();
		
		public function Main():void {
			super(init);
		}
		
		private var _dg:DataGrid;
		private var _dataProv:DataProvider;
		private var _btn1:Button;
		private var _btn2:Button;
		private var _btn3:Button;
		private var _itemsNum:Number = 50;
		
		private function init():void {
			_dg = new DataGrid(550, 15);
			
			var xmlQuery:XMLQuery = new XMLQuery();
			
			xmlQuery.add(
			<spas>
			<dataGridColumns>
			<item dataField="c1" headerText="One" width="50"/>
			<item dataField="c2" headerText="Two" width="50" />
			<item dataField="c3" headerText="Three" width="100"/>
			<item dataField="c4" headerText="Four" sortable="false"/>
			<item dataField="c5" headerText="Five" width="70" resizable="false"/>
			</dataGridColumns>
			</spas>
			);
			
			_dg.xmlQuery = xmlQuery;
			
			var c:Box = new Box(550, 50);
			c.horizontalGap = 15;
			
			var group:RadioButtonGroup = new RadioButtonGroup(c);
			
			var prop:DataProvider = new DataProvider();
			prop.addAll( { label:"50 items", data:50, selected:true }, { label:"100,000 items", data:100000 } );
			group.dataProvider = prop;
			
			_btn1 = new Button("Create Data");
			_btn2 = new Button("Populate");
			_btn3 = new Button("Remove All Data");
			_btn2.active = _btn3.active = false;
			
			c.addGraphicElements(_btn1, _btn2, _btn3);
			
			this.layout.orientation = LayoutOrientation.VERTICAL;
			this.addGraphicElements(c, _dg);
			
			$evtColl.addEvent(_btn1, UIMouseEvent.CLICK, createData);
			$evtColl.addEvent(_btn2, UIMouseEvent.CLICK, populateDataGrid);
			$evtColl.addEvent(_btn3, UIMouseEvent.CLICK, resetDataGrid);
			$evtColl.addEvent(group, ButtonsGroupEvent.GROUP_CHANGED, checkItemsNum);
		}
		
		private function checkItemsNum(e:ButtonsGroupEvent):void {
			_itemsNum = e.target.data;
		}
		
		private function resetDataGrid(e:UIMouseEvent):void {
			_dg.removeAll();
			_btn1.active = true;
			_btn3.active = false;
		}
		
		private function populateDataGrid(e:UIMouseEvent):void {
			_btn2.active = false;
			_btn3.active = true;
			_dg.dataProvider = _dataProv;
		}
		
		private function createData(e:UIMouseEvent):void {
			_btn1.active = false;
			_btn2.active = true;
			_dataProv = new DataProvider();
			var id:String;
			var i:uint = 1;
			for (; i<=_itemsNum; ++i) {
				id = String(i);
				_dataProv.add( {
					data:id, c1:String(id + ".One"), c2:String(id + ".Two"),
					c3:String(id + ".Three"), c4:String(id + ".Four"),
					c5:String(id + ".Five"), c6:String(id + ".Six")
					} );
				}
		}
	}
}

All of these features will be available with the SPAS 3.0 alpha 5.5. version.

Share this article:

Comments:

There are no comments yet for this article.

Leave a reply

Your email is required but will not be displayed.

To prevent abusive emails, please enter the numbers you see in the image below:

Security code