我正在尝试刷新datagrid以在用户更新数据库后反映更新的数据。那可能吗?我有以下代码:
脚本
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">
感谢您的帮助。
答案 0 :(得分:0)
最简单的方法是在服务成功响应时刷新dataProvider jobdata (您不希望在服务器抛出错误之前更新View)。如果您使用[Bindable]
对其进行标记,则数据网格会立即自动更新。
如果您希望使用唯一标识符(如果可用),也可以直接在dataProvider中替换单个项目。
答案 1 :(得分:0)
有两种方法可以做到:
更新数据库后,您可以再次检索数据 将其分配给数据提供者。
向数据库发送更新请求时,还会直接更新数据提供者。