有什么方法可以动态地将数据添加到网格中吗?

Is there any way to dynamically add data into a gird?

我有一个包含 n 个小部件的旋转木马,我想在用户聚焦旋转木马的最后一个项目后将另外 n 个项目加载到旋转木马。我在旋转木马中添加了 afteralign 事件侦听器以检测旋转木马项目之间和侦听器内部的导航 我创建了一个小部件并尝试使用 appendChildWidget() 方法将其附加到当前旋转木马

 _handleLazyLoading: function (evt) {
                var selectedItem = evt.target.getActiveChildWidget().getDataItem();
                if (selectedItem.page < selectedItem.totalPages) {
                    if (evt.target.getActiveChildIndex() === evt.target.getChildWidgetCount() - 3) {
                        var sampleData={"type":"VOD","id":1234,"accessLevel":"GRANTED","title":"sample","description":"A look back at all the Premier League action from the 31st of March 2018.","thumbnailUrl":"url of image","metaFields":{},"tags":
                        ["review","match-round-32"],"watchProgress":0,"favourite":true,"duration":3098,"watchedAt":1522675749000}
                        var videoCard=new CommonVideoCard(sampleData);
                        evt.target.appendChildWidget(sampleData)
                    }
                }
            }

这就是我的事件监听器代码。我也检查了 dom,如果我在附加方法之后放置一个断点,那么我可以在 dom 中看到数据,之后似乎特定的旋转木马被卡住了,我无法导航到轮播中的其他项目。 我只是尝试使用 removeWidget 方法,它有效。 非常感谢任何帮助。

在添加新的子窗口小部件后设置 setWidgetLengths(length);

所以代码看起来像

 _handleLazyLoading: function (evt) {
                var selectedItem = evt.target.getActiveChildWidget().getDataItem();
                if (selectedItem.page < selectedItem.totalPages) {
                    if (evt.target.getActiveChildIndex() === evt.target.getChildWidgetCount() - 3) {
                        var sampleData={"type":"VOD","id":1234,"accessLevel":"GRANTED","title":"sample","description":"A look back at all the Premier League action from the 31st of March 2018.","thumbnailUrl":"url of image","metaFields":{},"tags":
                        ["review","match-round-32"],"watchProgress":0,"favourite":true,"duration":3098,"watchedAt":1522675749000}
                        var videoCard=new CommonVideoCard(sampleData);
                        evt.target.appendChildWidget(sampleData);
                        evt.target.setWidgetLengths(620);
                    }
                }
            }