[flexcoders] Passing data to a cell on a DataGrid, and putting there a ComboBox

2009-01-19 Thread João
Hi,

My application has an AdvancedDataGrid that shows a list of data. I
would like that the user could edit data on the DataGrid itself just
by clicking on a row/cell. After the click, that cell shows a ComboBox
filled with data that comes from other data source different from the
datasource provided to the AdvancedDataGrid.

My problems are:

1- Best practices to pass the data (that comes from other datasource)
to the ComboBox on the cell ? Should I extend the ADG ?

2- To show the ComboBox on the cell, the proposed solution is to use
an itemRenderer or an itemEditor? What's the difference between both,
and which one of them fits better on my problem ?

3- After the user chooses the value, I need to save the change
somewhere. I am thinking on dispatching an event, with bubbles = true,
and catching it on the AdvancedDataGrid parent. Do you think this is a
good approach?

Thanks,

João Saleiro



RE: [flexcoders] Passing data to a cell on a DataGrid, and putting there a ComboBox

2009-01-19 Thread Tracy Spratt
One set of answers:

1- Assuming the ComboBox dataProvider is the same for all rows, you couild bind 
it to a data model on the main application.

2- If I recall correctly, using an itemEditor and editable column makes flex 
display the editor when you click in a cell.  You would use the normal DataGrid 
editing events to manipulate the data if needed.  If set up correctly, the DG 
will handle updating the dataProvider.  I tend to prefer non-editable columns 
containing full interactive itemRenderers that handle all of the display, and 
updating of the dataProvider item themselves.  The itemRenderer has a reference 
to the current dataProvider row item.  You can simply update the item there.  
Use the dataProvider API to update the item, to ensure the UI responds to the 
change.

3 - see 2 above

 

Additional notes:

*   itemRenderers should be be data driven.  You must update a renderers 
visual state based on changes to the underlying data.
*   If you want ComboBox to display the current cell value as the 
selectedItem, you will need to do some workl.
*   Interactive Item renderers are not simple, especially if youwant to 
perserve performance.  Find an example and modify it.  Do not start from 
scratch.   

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of João
Sent: Monday, January 19, 2009 12:03 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Passing data to a cell on a DataGrid, and putting there a 
ComboBox

 

Hi,

My application has an AdvancedDataGrid that shows a list of data. I
would like that the user could edit data on the DataGrid itself just
by clicking on a row/cell. After the click, that cell shows a ComboBox
filled with data that comes from other data source different from the
datasource provided to the AdvancedDataGrid.

My problems are:

1- Best practices to pass the data (that comes from other datasource)
to the ComboBox on the cell ? Should I extend the ADG ?

2- To show the ComboBox on the cell, the proposed solution is to use
an itemRenderer or an itemEditor? What's the difference between both,
and which one of them fits better on my problem ?

3- After the user chooses the value, I need to save the change
somewhere. I am thinking on dispatching an event, with bubbles = true,
and catching it on the AdvancedDataGrid parent. Do you think this is a
good approach?

Thanks,

João Saleiro