Hi All,
I'm trying to create a component to use as an example or 'template'
of how to achieve a record list and detail view in flex. I'm starting
with a simple 'contact' record (model) that has name, address, phone,
email, etc. The list of records is held in _dataProvider, and the
specific record to be displayed in the detail view is held in _model.
My goal is to have a nice clean skeleton of how to handle this sort of
display.
My component is a viewstack with 2 views:
View 0: a datagrid displaying summary info of a list of records
(title, first, last). Double click on an entry should
open it in the
'detail' view. dataProvider is bound to _dataProvider, an
arrayCollection.
View 1: a custom component that displays all my model fields.
It has a 'model' property that is used to set the
record to be displayed.
model is a single static instance of my record type, and
all fields in the
view are bound to it ( eg text='{_model.last_name}' )
The logic for the component is pretty simple:
1. Initial view is determined by _dataProvider.length
2. if _dataProvider.length = 1, default to 'detail' view of that record
3. if _dataProvider.length > 2, default to 'list' view
4. if _dataProvider.length = 0, add a new empty record and
default to 'detail'
view to allow data entry.
This mostly works - however, I run into 'odd' problems with
dataBinding and Initialization, etc. As my script gets cruftier with
all sorts of special case logic, and
manually poking stuff to get dataBindings updated, I wonder if perhaps
others have a better Design Pattern or template for this ??
I'd appreciate any feedback...