如何在使用xsjs插入数据库后从JSON模型刷新UI5表

时间:2022-06-06 16:53:27

I have a requirement to insert new records into db using UI5.Now I have a table displayed already in UI5 that shows existing data in that database table.I have used xsjs as the backend service and used JSON Model to display the UI5 table.Now I have to insert new records into the table . I have a xsjs at the backend which takes care of the insert in db table but even though the db table gets updated, my ui5 table data remains the same until I reload the page.I cannot directly update the UI5 table from front end using model array.push form values because there are certain meta parameters like updated by(current user ) and updated on (timestamp) fields which need to have values from live update.Please tell me how to update the UI5 table on record insertion ,without reloading the page.

我需要使用UI5将新记录插入到数据库中。现在我已经在UI5中显示了一个表,该表显示了该数据库表中的现有数据。我使用xsjs作为后端服务,并使用JSON模型显示UI5表。现在我必须在表格中插入新记录。我在后端有一个xsjs来处理db表中的插入但是即使db表更新了,我的ui5表数据仍然保持不变,直到我重新加载页面。我无法使用模型直接从前端更新UI5表array.push表单值,因为有某些元参数,如(当前用户)更新和更新(时间戳)字段需要从实时更新中获取值。请告诉我如何在记录插入时更新UI5表,而无需重新加载页。

2 个解决方案

#1


0  

Every minute or a period of time you could try to get the delta and update your data accordingly and then refresh the model. You can use OData filters http://www.odata.org/documentation/odata-version-2-0/uri-conventions/ to determine which records was generated during that period of time. Fields to be filtered depends on your scenario.

每分钟或一段时间,您可以尝试获取增量并相应地更新数据,然后刷新模型。您可以使用OData过滤器http://www.odata.org/documentation/odata-version-2-0/uri-conventions/来确定在该段时间内生成了哪些记录。要过滤的字段取决于您的方案。

#2


0  

I would do it the following way (in cnontroller):

我会用以下方式(在cnontroller中):

  1. Create getData() method which will trigger GET request to your xsjs
  2. 创建getData()方法,该方法将触发对xsjs的GET请求

  3. create onGetDataComplete(data) which will create and set the model to your table and executed as a callback of your success on getData()
  4. 创建onGetDataComplete(数据),它将创建模型并将其设置到表中,并作为getData()成功的回调执行

  5. Create putData() which will post to your xsjs
  6. 创建将发布到xsjs的putData()

  7. Create onPutDataComplete() which will be executed as a call back of your success on putData(). In this method you can call getData() again and you will have your updated stuff.
  8. 创建onPutDataComplete(),它将作为putData()成功的回调执行。在这种方法中,你可以再次调用getData(),你将获得更新的东西。

#1


0  

Every minute or a period of time you could try to get the delta and update your data accordingly and then refresh the model. You can use OData filters http://www.odata.org/documentation/odata-version-2-0/uri-conventions/ to determine which records was generated during that period of time. Fields to be filtered depends on your scenario.

每分钟或一段时间,您可以尝试获取增量并相应地更新数据,然后刷新模型。您可以使用OData过滤器http://www.odata.org/documentation/odata-version-2-0/uri-conventions/来确定在该段时间内生成了哪些记录。要过滤的字段取决于您的方案。

#2


0  

I would do it the following way (in cnontroller):

我会用以下方式(在cnontroller中):

  1. Create getData() method which will trigger GET request to your xsjs
  2. 创建getData()方法,该方法将触发对xsjs的GET请求

  3. create onGetDataComplete(data) which will create and set the model to your table and executed as a callback of your success on getData()
  4. 创建onGetDataComplete(数据),它将创建模型并将其设置到表中,并作为getData()成功的回调执行

  5. Create putData() which will post to your xsjs
  6. 创建将发布到xsjs的putData()

  7. Create onPutDataComplete() which will be executed as a call back of your success on putData(). In this method you can call getData() again and you will have your updated stuff.
  8. 创建onPutDataComplete(),它将作为putData()成功的回调执行。在这种方法中,你可以再次调用getData(),你将获得更新的东西。