Skip to main content
Known Participant
January 16, 2013
Answered

Dataprovider question

  • January 16, 2013
  • 1 reply
  • 999 views

Hi

Just a small area of dataProvider code I am 5% unsure of.

When you populate a provider with an object, eg...

myData = JSON.parse(event.target.data);// add JSON to object

listDP = new DataProvider(myData);// add object to dataProvider

data_grid.dataProvider = listDP;//set datagrid's dataProvider

...when you are making edits to the data, do you edit myData, and then to update the dataProvider...

listDP = new DataProvider(myData);// update dataProvider

...or do you somehow edit listDP directly?

Another way to ask...

...if the above was in an editable datagrid, when you make an edit, does Flash update myData, then do listDP = new DataProvider(myData); , or does it directly edit listDP?

Thanks guys

This topic has been closed for replies.
Correct answer kglad

the dataProvider property of your datagrid will update so you would use:

listDP=data_grid.dataProvidier

to update listDP (which does not save json data anywhere).

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 16, 2013

the dataProvider property of your datagrid will update so you would use:

listDP=data_grid.dataProvidier

to update listDP (which does not save json data anywhere).

Known Participant
January 18, 2013

Thanks kGlad

What if I'm not editing in the datagrid, but programatically adding data to it (from an external source)...

Example set up:

myData = JSON.parse(event.target.data);// add JSON to object

listDP = new DataProvider(myData);// add object to dataProvider

data_grid.dataProvider = listDP;//set datagrid's dataProvider

...and then I get some external data that needs to be added, do I add it to myData, or listDP? Currently I'm adding it to myData, then re-adding the line listDP = new DataProvider(myData); to update the datagrid.  Should I just be adding the data directly to listDP, and not myData?

kglad
Community Expert
Community Expert
January 18, 2013

you could do that, you could add data directly to listDP and you could add the data directly to data_grid.

i would use one of the latter two because i don't like creating new objects unless necessary.  you're not creating a potential memory problem with that because you use the same variable (listDP) but you will be adding additional (over the latter two methods) work for garbage collection.  but i don't foresee a performance problem creating new listDP objects unless you're doing that frequently.