Update certain rows in datagrid from database
Hi guys
Thanks for answering a couple of my other questions in the last day or so - I haven't got to properly going through them as I have been working on my database/datagrid interaction, and it's been all consuming. I'm almost done, but...
...I'm wondering what the best way is to retrieve certain rows from a database, and use them to overwrite the related rows in a datagrid?
My datagrid's dataprovider looks like...
song_id, title, artist, ...
... where song_id corresponds to the song_id primary key column in my database.
Rather than repopulate the whole datagrid by selecting all the rows in the database, I'm selecting certain rows using WHERE IN ( 2, 6, 77, 999... ) in my query, and am wondering how to use to the song_id in the returned data to find the correct row to overwrite in the datagrid.
I'm unsure how to fill in the blanks...
var L = returnedDatabaseResultsArray.length;// length of array of objects returned by my WHERE IN ( 2, 6, 77, 999... )
for (var i:int = 0; i < L; i++)
{
var _rowNumber:int = returnedArray(i).song_id;//extract song_id out of this row of returned data
//find the row in the dataprovider that contains song_id, then (what goes here?)...
data_grid.dataProvider.replaceItemAt( returnedDatabaseResultsArray(i), _rowNumber );// overwrite that row with this row from database
}
Cheers guys
