SAPUI5 过滤器 table 性能

SAPUI5 filter table performance

我有一个 table,其中 3 列最多包含 6000 个元素。在那个 table 之上我有一个 SearchField。当在 SearchField 中输入内容时,table 被 3 列中的 2 列过滤(使用 liveChange),如下所示:

var oTable = this.getView().byId("idMyTable");
var oBinding = oTable.getBinding("items");
oBinding.filter(new sap.ui.model.Filter([
                    new sap.ui.model.Filter("col1", sap.ui.model.FilterOperator.Contains, sInput),
                    new sap.ui.model.Filter("col2", sap.ui.model.FilterOperator.Contains, sInput),

                ], false), "Application");

虽然此解决方案有效,但它几乎需要 5 秒 才能完成(对于 table 中的 6000 个元素),并且还需要一点时间才能完成table 再次显示。

填充table时,其大小限制设置为模型中数据的长度:

// rs0 is the result set of the db query which contains the data
tableModel.setSizeLimit(tableModel.getData().rs0.length);

当我省略对 setSizeLimit 的调用时,搜索速度非常快,但我无法滚动浏览 table 中的所有项目(并非显示所有内容)。

我的问题是:如何显示 table 中的所有值并同时保持良好的搜索性能?

提前致谢!

默认情况下,我认为 sizeLimit 设置为 100,并且 table/list 的默认增长是 20(这意味着它只会显示 20 个元素,直到用户向下滚动,它会加载另一个20 个元素的块)。

这是默认行为,否则,您会遇到那种延迟问题。

我不知道是否有办法改善这种行为,但目前这是最好的解决方案。

你可以做的是在 OpenUI5 GitHub project 上打开一个特定的问题并寻求建议。

我终于找到了解决问题的方法。我现在没有在模型上使用 setSizeLimit,而是在 table 本身上使用 grow 属性。这允许我的 table 在用户向下滚动时按时间加载数据。因此我的 table 声明现在看起来像这样:

<Table [...] visibleRowCountMode="Fixed" visibleRowCount="8" growing="true" 
    growingScrollToLoad="true" growingThreshold="100" threshold="100" >

增长 属性 描述如下:

https://sapui5.netweaver.ondemand.com/1.30.7/docs/guide/9164ba7047b74a25a19baf9c5bb986ae.html

摘录(如果 link 死亡):

growing: Boolean to set the growing feature to on or off
growingScrollToLoad: If you want to allow more data to be fetched when the user scrolls down to the end of the current items, set this boolean property to true; otherwise a trigger button must be used
growingThreshold: The number of items that are requested each time from the model
growingTriggerText: The text on a trigger button used to cause a request for more data