I am trying to refresh the datagrid to reflect the updated data after the user updates the database. Is that possible? I have the following code:
script
protected function updataHandler(event:MouseEvent):void
{
updateJobsResult.token = Service.updateJobs(updateJobData);
//The database will be updated after users click the update button
//I want to update datagrid dataprovider to show the updated data.
}
<s:datagrid dataprovider="jobdata">
//jobdata comes from from database query
..................
..................
</datagrid>
<s:form>
//when user selects the row in datagrid, the cell values will
//pop in this form and user can update the form
.................
.................
</form>
<s:button click="updateHandler">
Thanks for the help.
The easiest way is to just refresh the dataProvider jobdata when service responds successfully (you don't want to update the View before in case the server throws an error). If you tag it with [Bindable]
the datagrid will auto update immediately.
You can also replace individual items directly in the dataProvider if you prefer using a unique identifier if available.
There are two ways to do that:
after update the database, you can retrieve the data again and assign it to the dataprovider.
when you send a update request to the database, you also update the dataprovider directly.