sap.m.list - 隐藏一行

时间:2017-02-01 09:32:07

标签: list sapui5 sap.m

我有一个问题,希望能找到帮助。在sap.m.page上,我已经放置了一个列表(sap.m.list)

new sap.m.Page(
            "mainPage", {
                title : "",
                enableScrolling : true,
                content : [
                    oList = new sap.m.List("items", {
                        threshold : 2,
                        inset : false,
                        headerText : "Aufträge",
                        //filters : filters,
                        columns : [
                            new sap.m.Column({
                                hAlign : "Left",
                                width : '45px',
                                //styleClass : "qty",
                                header : new sap.m.Label({
                                    text : "Station"
                                })
                            }),
                            new sap.m.Column({
                                hAlign : "Left",
                                width : '40px',
                                header : new sap.m.Label({
                                    text : "Zeit"
                                })
                            }),
                            new sap.m.Column({
                                hAlign : "Left",
                                width : '20px',
                                header : new sap.m.Label({
                                    text : ""
                                })
                            }),      
                            new sap.m.Column({
                                hAlign : "Left",
                                width : '20px',
                                header : new sap.m.Label({
                                    text : ""
                                })
                            }),                                 
                            new sap.m.Column({
                                hAlign : "Left",
                                width : '50px',
                                header : new sap.m.Label({
                                    text : "Raum"
                                }),
                                minScreenWidth : "Phone"//XXSmall"
                                //demandPopin : true
                            }),
                            new sap.m.Column({
                                hAlign : "Left",
                                width : '40px',
                                header : new sap.m.Label({
                                    text : "Bett"
                                }),
                            }),
                            new sap.m.Column({
                                hAlign : "Left",
                                width : '20px',
                                //styleClass : "qty",
                                header : new sap.m.Label({
                                    text : "St."
                                })
                            }),
                             new sap.m.Column({
                                hAlign : "Left",
                                width : '20px',
                                //styleClass : "qty",
                                header : new sap.m.Label({
                                    text : "Typ"
                                })
                                (...)

对于条目,我有一个模板定义

//Template für die Listzeilen
            var template = new sap.m.ColumnListItem({
                type : "Navigation",
                cells : [
                    new sap.m.Label({
                        text: "{Orgpf}"
                    }),
                    new sap.m.Label({
                        text : "{Uhrzeit}"
                    }),
                    new sap.ui.core.Icon({
                        src: "{IconTermin}"
                    }),  
                    new sap.ui.core.Icon({
                        src: "{IconAufbereitung}"
                    }),                                 
                    new sap.m.Label({
                        text: "{Bett}"
                    }),
                    new sap.m.Label({
                        text: "{Bettnr}"
                    }),
                    new sap.m.Label({
                        text : "{Status02}"
                    }),
                    new sap.m.Label({
                        text: "{Betttyp}"
                    })

(...)

列表的数据来自我们的sap网关的odata服务。我用下面的例行程序填写表格

 var filter = new sap.ui.model.Filter("Team", sap.ui.model.FilterOperator.EQ, localStorage.getItem("Team"));    
            oList.bindAggregation("items", { path: "/AuftragSet", filters: filter, template});

这很好用。

问题:加载条目后不应显示所有条目。处理具有特殊类型的visibile条目后,现在应该可以看到相应的条目。我不想再次使用该服务读取数据,因为我没有在所有地方访问互联网。因此,我选择更多条目,并需要隐藏其中一些。我怎么解决这个问题?我在哪里可以设置过滤器?

THX为你的答案。

亲切的问候,

Sven

2 个答案:

答案 0 :(得分:0)

在您的情况下,过滤器不是一个好选择,因为您要下载所有数据并显示少数几个。另一方面,过滤器将导致服务器返回选择几行超出您的目的。

您可以使用visible的继承sap.m.ColumnListItem属性。定义模板时,添加visible属性并将其绑定到OData属性。

var template = new sap.m.ColumnListItem({
type: "Navigation",
visible: "{put you OData determining property here}",
cells: [...]
});

此外,考虑使用sap.m.Table或其子类之一作为sap.m.List,不建议使用列。 https://sapui5.hana.ondemand.com/docs/api/symbols/sap.m.List.html#addColumn

使用此链接决定使用哪个表格:https://sapui5.hana.ondemand.com/#docs/guide/148892ff9aea4a18b912829791e38f3e.html

希望这会有所帮助。

答案 1 :(得分:0)

过滤掉要绑定表的数据是一种很好的方法。找到以下链接,了解如何在OData服务成功时过滤表格或列表:sapui5-how-to-filter-data-with-2-or-more-values

相关问题