0

I have a datagrid that uses an array of objects as the data provider. The objects are essentially key/value pairs: { foo:"something"} { bar:"hello"} { caca:"lorem"} The datagrid has 2 columns. The first column is the key and the second column is the value. Right now my grid looks like:

My dataFormatter function makes sure that depending on the column (i.e. the dataField value) the correct key or value gets printed out. This works fine for displaying. However, as soon as I try and edit the value field it essentially adds a new value into the object with a key of '1'. For example, if I edit the {caca:"lorem"} object it will then contain the value {caca:"lorem",1:"new value"}.

Is there any possible way I can set the DataGridColumn so that when I edit a value it will update the value associated with the key rather than inserting a new value? I've tried using a custom item editor but it still does the insert. It seems like I need to be able to update the 'dataField' with the actual key value but I'm not sure how to do that.

rforte
  • 1,167
  • 1
  • 11
  • 21
  • var arr:Array = new Array(); // // setup key/value pair of objects // arr.push( {foo:"bar"} ); arr.push( {cat:"dog"} ); arr.push( {kick:"tothegroin"} ); var ac:ArrayCollection = new ArrayCollection( arr ); ... p.s. I'm typing this off the top of my head. – rforte Mar 25 '10 at 21:44
  • wow, the above is not readable. is it possible to format code in a comment? – rforte Mar 25 '10 at 21:45

1 Answers1

0

Looks like you need to think about where your data is going to be stored. I would recommend listening for a CollectionEvent.COLLECTION_CHANGE event on your data model. That event object will contain info about what change occurred, and you can make any updates you need to make.

akh
  • 1