TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman [email protected] Blog:
-
Upload
colin-underwood -
Category
Documents
-
view
221 -
download
3
Transcript of TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman [email protected] Blog:
![Page 1: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/1.jpg)
TAMING OF THE BEAST
Flex AdvancedDataGrid
Drew [email protected]
Blog: http://squaredi.blogspot.com/
![Page 2: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/2.jpg)
Who are you?
Freelance Developer / Architect with 15 years of professional multimedia experience
Certified Flex Expert / InstructorProfessor of Multimedia @ University of
Houston
Just finished 4+ months of AdvancedDataGrid customization for a client
![Page 3: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/3.jpg)
What are you talking about today?
Useful design patterns for extending the grid, focusing on focus control examples
Bugs and gotcha’s within the grid
![Page 4: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/4.jpg)
Outline
Extending the ADGDesign PatternsExisting Bugs & Defects Show me the Code – Focusing on FocusFile StructureQ&A
![Page 5: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/5.jpg)
What sort of unique focus requirements?
0,1, or 2 editable fields per cellGrouping and expanded rows that don’t have
any focusable fieldsClicking anywhere in the row focuses on
editable cellFirst editable field gets focus when the grid
appearsSome products are not editableSet focus to a particular item from outside
the grid
![Page 6: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/6.jpg)
What sort of unique requirements?
![Page 7: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/7.jpg)
Guiding Design Principles
Very easy to read and understandSwappable functionality on an instance levelSingle reference point for all gridsUnit TestableEfficient; enabling features only as needed100% decoupled from Data, Models,
FrameworkStill *is* an AdvancedDataGrid to the
developers
![Page 8: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/8.jpg)
So how do you meet your goals?
Delegate as much work as possible to other classes
Keep methods small (<5 lines) to make it readable
Create as many “seams” as possible
![Page 9: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/9.jpg)
Is there a key ingredient to focus?
Q: What happens internally when we focus into an editable cell?
A: 1. editedItemPosition is updated to reflect
the row & column index of the edited position
2. An itemEditorInstance is created. Even if the renderIsEditor = true, you still get a new instance.
![Page 10: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/10.jpg)
SHOW ME THE FOCUS!
Demo
![Page 11: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/11.jpg)
WARNING:SOME MIGHT BE CUSTOM
OR NEWLY CREATEDDUE TO LIMITED RESEARCH TIME
Design Patterns
![Page 12: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/12.jpg)
Accessor Pattern
Purpose:Provides access to public properties of a class.
Implementation:In its simplest form, it exposes the same public properties as the class that it is exposing. It is needed for unit testing, in which setting some of these properties creates a series of events that is difficult to test.
var gridAccessor:IGridAccessor = new GridAccessor(this);
Example reference: GridFocusDelegate constructor
![Page 13: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/13.jpg)
Evaluator Pattern
Purpose:To extract common business questions into a method that typically returns a boolean
Implementation:if (evaluator.isProductInOrder(product))if (evaluator.isProductOrderable(product))if (evaluator.isProductPromotion(product))
Example reference GridFocusDelegate -> isDataRowIndexEditable()
![Page 14: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/14.jpg)
Delegate Pattern
Purpose:To offload all additional functionality, calculations, processing, etc that doesn’t directly set a property on the grid.
Example reference ADGSeam -> setFocusFirst()
![Page 15: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/15.jpg)
GOTCHA’S, PITFALLS,DEFECTS,
AND OTHER HIDDEN “FEATURES”
Bug Fixes? Like What
![Page 16: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/16.jpg)
Problem Solution
When tabbing, it is really hard to tell it to ignore a particular item
Like an out of stock item or a read only item
Override protected method isDataEditable
Defect: findNextItemEditor
Example reference
![Page 17: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/17.jpg)
Problem Solution
If you have editable=“true”
Yet you don’t set any columns to editable=“true”
RTE on the focusInHandler, which could occur on Tab or setFocus()
Override focusInHandler to error handle editedItemPosition which is left “out of range” after an internal for loop
Bug: editable=“true”
Example reference
![Page 18: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/18.jpg)
Problem Solution
RendererProviders take an explicit columnIndex
Yet, they could span all of the columns
If the first column is hidden, the rendererProvider doesn’t show at all.
Track the columnIndecies
Shift referenced values when a column is hidden
Defect: RendererProviders
Example reference
![Page 19: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/19.jpg)
Problem Solution
Dragging and editable enabled
renderIsEditor = true
User is unable to select/hilight field without dragging
Override mouseMoveHandler and check for an itemEditorInstance != null
Defect: Dragging an editable grid
![Page 20: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/20.jpg)
Problem Solution
Column sort appliedEdit a field in that columnWhen user commits (tabs
away), the row might disappear based on sort.
Scenario: Sort on quantity. Change 3 to 10. Row of interest jumps offscreen to meet sort critiera
Disable sorting when editing the sorted field.
Defect: Editing a sorted field
![Page 21: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/21.jpg)
Problem Solution
HierarchicalViewCollection doesn’t listen for a refresh event on its underlying source collection
Specifically watch for the “filterFunctionChanged” event and manually call refresh on the HierarchicalCollection
Bug: HierarchicalViewCollection refresh
![Page 22: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/22.jpg)
Problem Solution
Reusing a dataprovider with open nodes, will cause a performance slowdown due to caching of openNodes
hierarchicalCollectionView.openNodes = {}
Bug: HierarchicalCollectionView openNodes
![Page 23: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/23.jpg)
HOW TO SET UP THESE FILES
Structure
![Page 24: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/24.jpg)
Structure
MyADGBugFixSpecifically for Flex based bugs
MyADGBaseClassUsed as a extensible library for common features
ClientADGBaseClassSpecific client functionality
ClientADGFactoryEnumerate all of the grids that the client has
![Page 25: TAMING OF THE BEAST Flex AdvancedDataGrid Drew Shefman dshefman@squaredi.com Blog:](https://reader036.fdocuments.us/reader036/viewer/2022062321/56649f2b5503460f94c45e33/html5/thumbnails/25.jpg)
DREW SHEFMANDSHEFMAN@SQUAREDI .COM
BLOG: HTTP: / /SQUAREDI.BLOGSPOT.COM/
Q & A