我正在尝试用我手动完成的数组替换模型中的数据来过滤自己。我从model.read()获取此数据。问题是ui5中模型中更新数据的记录方式都没有工作,甚至似乎都没有响应被调用。我正在使用odata v2,但所有这些技术都记录在v2模型中:https://openui5.hana.ondemand.com/docs/topics/6c47b2b39db9404582994070ec3d57a2.html
filterFeed: function() {
var model = this.getOwnerComponent().getModel();
var view = this.getView();
model.read("/assessmentFeed", {
success: function(odata) {
var comments = odata.results;
var results = [];
// ... do work to fill 'results'
model.setProperty('/assessmentFeed', results);
var json = new sap.ui.model.json.JSONModel(results);
view.setModel(json, "/assessmentFeed");
var list = view.byId("feedList");
list.bindAggregation("items", "/assessmentFeed", new sap.m.FeedListItem());
}
});
},
这是我的xml视图中的Feed列表
<layout:content>
<m:FeedInput post="onFeedPost" class="sapUiSmallMarginTopBottom"/>
<m:List id="feedList" showSeparators="Inner" items="{path: '/assessmentFeed', sorter: {path: 'DATE', descending: true}}">
<m:FeedListItem sender="{MEMBERID}" timestamp="{DATE}" text="{COMMENT}" convertLinksToAnchorTags="All"/>
</m:List>
</layout:content>
在调用上述所有功能后,我没有收到任何错误但没有明显的效果。
这来自模型的aBindings数组,显示evaluateFeed位于模型的chrome调试器绑定中。
答案 0 :(得分:1)
为什么要尝试将数据放在JSON模型和oData模型中?
控制器:
filterFeed: function() {
var model = this.getOwnerComponent().getModel();
var view = this.getView();
var json = new sap.ui.model.json.JSONModel(); //New JSON model
model.read("/assessmentFeed", {
success: function(odata) {
var comments = odata.results;
var results = [];
// ... do work to fill 'results'
view.setModel(json, "JSON"); //Set json model and name it JSON
json.setProperty("/assessmentFeed", results); //Push results into your json model with path /assessmentFeed
}
});
查看:绑定路径为JSON>/assessmentFeed
<layout:content>
<m:FeedInput post="onFeedPost" class="sapUiSmallMarginTopBottom"/>
<m:List id="feedList" showSeparators="Inner" items="{path: 'JSON>/assessmentFeed', sorter: {path: 'DATE', descending: true}}">
<m:FeedListItem sender="{JSON>MEMBERID}" timestamp="{JSON>DATE}" text="{JSON>COMMENT}" convertLinksToAnchorTags="All"/>
</m:List>
</layout:content>