过滤sapui5中的ODATA模型并与tilecontainer绑定
Filter ODATA Model in sapui5 and bind with tilecontainer
我正在 xml 视图中绑定我的图块容器
<TileContainer id="idsolutionContainer" tiles="{ path: 'dlCourses>/DLES_COURSE_CONTENT' }">
<tiles>
<dles:DLESScoreTile name="{dlCourses>LJ_TITLE}" topicId="{dlesScore>ID}" topic="{dlCourses>LJ_SOLUTION}" dles="{dlCourses>DLES}" id="tileDLESCourse" press=".handleCourseClick"></dles:DLESScoreTile>
</tiles>
</TileContainer>`
并且在 inint 函数的后端,我试图通过 LJ_SOLUTION
进行过滤,但它不起作用。它给了我所有的课程。我从查询字符串中得到 LJ_SOLUTION,这就是我不在前端进行过滤的原因。
代码为
var coursePath = "/DLES_COURSE_CONTENT";
var filterByName = new sap.ui.model.Filter('LJ_SOLUTION', 'EQ', 'Analytics')
//sPath = "/DLES_SOLUTION_CONTENT?$filter=LJ_SOLUTION eq '" + sId + "')";
var courses = oView.getModel("dlCourses");
var courseData = oModel.getData(coursePath);
oView.bindElement({
path: coursePath,
filters: [ new sap.ui.model.Filter("LJ_SOLUTION",sap.ui.model.FilterOperator.EQ, "Analytics") ],
model: "dlCourses",
events: {
dataRequested: function() {
oView.setBusy(true);
},
dataReceived: function() {
oView.setBusy(false);
}
}
});
网络选项卡...
还有另一个我不完全理解的请求批次,但请求查询是
请删除代码“var courseData = oModel.getData(coursePath);”
因为这会加载整个模型。 bindElement 还将创建一个仅加载所需数据的请求。然后,检查由 bindElement 创建的请求以查看 “LJ_Solution”
的路径是否正确。
var oView = this.getView();
var oSolutionJourneyList = oView.byId("idsolutionContainer");
var oBinding = oSolutionJourneyList.getBinding("tiles");
if (oBinding) {
var oFilter = new sap.ui.model.Filter("LJ_SOLUTION", 'EQ', 'Analytics');
oBinding.filter([oFilter]);
}
我正在 xml 视图中绑定我的图块容器
<TileContainer id="idsolutionContainer" tiles="{ path: 'dlCourses>/DLES_COURSE_CONTENT' }">
<tiles>
<dles:DLESScoreTile name="{dlCourses>LJ_TITLE}" topicId="{dlesScore>ID}" topic="{dlCourses>LJ_SOLUTION}" dles="{dlCourses>DLES}" id="tileDLESCourse" press=".handleCourseClick"></dles:DLESScoreTile>
</tiles>
</TileContainer>`
并且在 inint 函数的后端,我试图通过 LJ_SOLUTION
进行过滤,但它不起作用。它给了我所有的课程。我从查询字符串中得到 LJ_SOLUTION,这就是我不在前端进行过滤的原因。
代码为
var coursePath = "/DLES_COURSE_CONTENT";
var filterByName = new sap.ui.model.Filter('LJ_SOLUTION', 'EQ', 'Analytics')
//sPath = "/DLES_SOLUTION_CONTENT?$filter=LJ_SOLUTION eq '" + sId + "')";
var courses = oView.getModel("dlCourses");
var courseData = oModel.getData(coursePath);
oView.bindElement({
path: coursePath,
filters: [ new sap.ui.model.Filter("LJ_SOLUTION",sap.ui.model.FilterOperator.EQ, "Analytics") ],
model: "dlCourses",
events: {
dataRequested: function() {
oView.setBusy(true);
},
dataReceived: function() {
oView.setBusy(false);
}
}
});
网络选项卡...
请删除代码“var courseData = oModel.getData(coursePath);”
因为这会加载整个模型。 bindElement 还将创建一个仅加载所需数据的请求。然后,检查由 bindElement 创建的请求以查看 “LJ_Solution”
的路径是否正确。
var oView = this.getView();
var oSolutionJourneyList = oView.byId("idsolutionContainer");
var oBinding = oSolutionJourneyList.getBinding("tiles");
if (oBinding) {
var oFilter = new sap.ui.model.Filter("LJ_SOLUTION", 'EQ', 'Analytics');
oBinding.filter([oFilter]);
}