刷新字段值

Refreshing values on fields

我的应用程序中有多个页面,其中之一是添加驱动程序信息。

当我转到添加驱动程序信息页面并填写一些字段,如 "driver licence" 文本框时,我不会将其添加到数据库并单击 "go back" 按钮(丢弃更改并回到主页)当我再次进入这个页面时,我之前填写数据的字段没有清除和刷新(它应该所有字段都是清晰和空的)

有人对此有解决方案吗?

“返回按钮”代码:

app.datasources.driver.clearChanges(function() {
    console.log("cleared changes");
});
returnToDriver();

returnToDriver() 代码为:

app.datasources.DRIVERS_LIST.query.clearFilters();
app.datasources.DRIVERS_LIST.load();
app.showPage(app.pages.Driver);

已经尝试过:

widget.root.descendants.TextBox1.value = "";
widget.root.descendants.TextBox1.value  = null;

但对我不起作用。

此致

可能有多种离开页面的方法:

  • 包括导航热键的浏览器导航
  • 页面上可以导航到其他页面的链接
  • in-app导航buttons/hotkeys
  • 等...

处理所有可能的导航场景的最佳方法是使用 onDetach 页面事件

// Implicit way
// page onDetach event handler, assuming that page
// is bound to appropriate datasource:
// @datasources.<MyDatasource>.modes.create
widget.datasource.clearChanges();

// Explicit way
// Explicitly clearing changes for create datasources in
// page onDetach event handler
app.datasources.<MyDatasource1>.modes.create.clearChanges();
app.datasources.<MyDatasource2>.modes.create.clearChanges();
...

将此代码添加到 onDetach 页面的事件处理程序后,您可以从页面中删除所有其他 clearChanges 事件。