在sapui5中过滤ODATA模型并与tilecontainer绑定

时间:2017-09-11 16:06:33

标签: odata sapui5 sap-fiori

我在xml视图中将我的tile容器绑定为

    <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>`

并且在onint fucntion的后端我试图按LJ_SOLUTION进行过滤,但它不起作用。它给了我所有的课程。我从查询字符串中获取LJ_SOLUTION,这就是为什么我在前端不是filtring的原因。 代码是

        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);
                }
            }
        });

网络标签... DLES_COURSE_CONTENT REQUEST 还有另一个请求批处理我完全不理解,但请求查询是 batch Request Query

2 个答案:

答案 0 :(得分:1)

            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]);
            }

答案 1 :(得分:0)

请删除代码“var courseData = oModel.getData(coursePath);”

因为这会加载整个模型。 bindElement还将创建仅加载所需数据的请求。然后,检查bindElement创建的请求,以查看“LJ_Solution”的路径是否正确。