Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Scenario one
- // -------------
- // Dataprovider is set of objects
- // Datafield of Gridcolumn is mapped with object properties
- // Now we can access the new value from dataprovider.
- import spark.components.DataGrid;
- var sparkDataGrid:DataGrid = new DataGrid();
- sparkDataGrid.addEventListener(GridItemEditorEvent.GRID_ITEM_EDITOR_SESSION_SAVE, handleGridItemEditEnd);
- private function handleGridItemEditEnd(event:GridItemEditorEvent):void
- {
- var newValue:String = (event.currentTarget as CustomSparkDataGrid).dataProvider[event.rowIndex][event.columnIndex];
- }
- // Scenario Two
- // -------------
- // Dataprovider is set of objects
- // Label function to set custom cell-display value and datafield is not mapped
- // Label function return value, take precedence as dataField is Null
- // so we can't access the new value from dataprovider
- import spark.components.DataGrid;
- import spark.components.gridClasses.GridItemEditor;
- import spark.components.gridClasses.IGridItemEditor;
- var sparkDataGrid:DataGrid = new DataGrid();
- sparkDataGrid.addEventListener(GridItemEditorEvent.GRID_ITEM_EDITOR_SESSION_SAVE, handleGridItemEditEnd);
- private var destroyedItemEditor:IGridItemEditor;
- // Griditem Editor - gets destroyed before dispatching the save event -
- // So its important to get its reference .
- private function handleGridItemEditStart(event:GridItemEditorEvent):void
- {
- destroyedItemEditor = (event.currentTarget as DataGrid).itemEditorInstance;
- }
- // Griditem Editor - gets destroyed before dispatching the save event -
- // hence itemEditorInstance will be null at this stage
- // We can't access the value from dataprovider as we use label function to set the cell display ,
- // instead of dataField value
- private function handleGridItemEditEnd(event:GridItemEditorEvent):void
- {
- if(destroyedItemEditor){
- // As IGrid Itemeditor doesn't provide getter method to access value
- // we have to cast as base class to get the value property
- // It important for us, to make sure when we create our own custom editor , it extends Grid item editor base class
- // and override getter and setter of value method
- var newValue:String = (destroyedItemEditor as GridItemEditor).value as String;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement