What's the correct way to bind data to a DataGrid component?
I am having some trouble to properly bind data to a DataGrid component, some .NET friends of mine showed me how easy it's for them, they just set the binding relation and it works quite smooth, the data is still there with the same row selected no matter if you poll the database every 5 seconds or click on the DataGrid header to change the sorting criteria, this is something that I haven't been able to achieve on Flash with the DataGrid control, I wonder if this control is really that difficult to use or if I am doing something wrong. I am for the latest.
The way I am using the DataGrid control is by setting its dataProvider property every time I poll the database, it looks similar to this...
//Populate the DataGrid component.
//This method will be called every 5 seconds from
//a Webservice onResult callBack.
//Define an array to use it as a dataProvider for the dataGrid component.
var myDataGrid_Data_Array = new Array();
//Bind the array of data to the DataGrid's dataProvider property.
myDataGridComponent.dataProvider = myDataGrid_Data_Array;
for (i in someDataFromWebserviceCall)
//Extract data from a hypothetical Webservice response...
var tmp_Data = someDataFromWebserviceCall[i];
//...and add the data to the array of data which was
//binded to the dataProvider property.
myDataGrid_Data_Array[i] = tmp_Data;
I see what I am doing wrong in here and I don't know another way to do it, it must be another way. The problem is that I am re-setting the data array every time I poll for new data and so, for the DataGrid component it looks like new data every time I get data, it's not like updating data.
I have been reading about using the DataSet component, populating this component with the data, binding its dataProvider to the DataGrid's dataProvider and some use of the deltaPacket property but, honestly, I don't know how to do it.
If someone could summarise -schematically, I don't need detailed code- how to properly show data on a DataGrid which update repeatedly, where the final user can operate it to change the sorting criteria without loosing any selected row, that will be fantastic. Or point me out to the right document, article, link, something that could help me on making a good use of this component.
I know that many questions has been asked about the DataGrid component and I think that most of those are related to the same bottom line problem, that this component is not been used properly, we are missing something in here.
Thank you very much for any help.