我目前正在为我的公司开发 MasterDetail 应用程序,该应用程序提供以节点表示的可扩展类别。
\n\n节点及其子节点与导航属性的绑定不是问题。但是,如果我想在上面的搜索字段中搜索某个组节点,它只会在四个最高节点之间进行过滤。它可以搜索第一层的节点,但无法找到第一层以下的节点。
\n树的绑定:
\n<Tree\n selectionChange="onSelectionChange"\n id="list"\n noDataText="{masterView>/noDataText}"\n busyIndicatorDelay="{masterView>/delay}"\n items="{path: \'/GroupNodes\',\n parameters : {\n expand: \'ChildGroupNodes\',\n navigation: {\n \'GroupNodes\': \'ChildGroupNodes\'\n }\n }\n }">\n <StandardTreeItem \n title="{Stext}"\n type="Navigation"\n press="onSelectionChange"/>\n</Tree>\nRun Code Online (Sandbox Code Playgroud)\n在搜索上:
\n onSearch: function(oEvent) {\n if (oEvent.getParameters().refreshButtonPressed) {\n this.onRefresh();\n return;\n }\n\n var sQuery = oEvent.getParameter("query");\n if (sQuery) {\n this._oListFilterState.aSearch = [new Filter("Stext", FilterOperator.Contains, sQuery)];\n } else {\n this._oListFilterState.aSearch = [];\n }\n this._applyFilterSearch();\n },\nRun Code Online (Sandbox Code Playgroud)\n_applyFilter搜索:
\n _applyFilterSearch: function() {\n var aFilters = this._oListFilterState.aSearch.concat(this._oListFilterState.aFilter),\n oViewModel = this.getModel();\n\n this._oList.getBinding("items").filter(aFilters, "Application");\n \n if (aFilters.length !== 0) {\n oViewModel.setProperty("/noDataText", this.getResourceBundle().getText("masterListNoDataWithFilterOrSearchText"));\n } else if (this._oListFilterState.aSearch.length > 0) {\n oViewModel.setProperty("/noDataText", this.getResourceBundle().getText("masterListNoDataText"));\n }\n },\nRun Code Online (Sandbox Code Playgroud)\nonInit()函数中的Filterstate:
\nthis._oListFilterState = {\n aFilter: [],\n aSearch: []\n};\nRun Code Online (Sandbox Code Playgroud)\n元数据:
\n<EntityType Name="GroupNode" sap:content-version="1">\n <Key>\n <PropertyRef Name="Grpid"/>\n </Key>\n <Property Name="Grpid" Type="Edm.String" Nullable="false" MaxLength="8" sap:unicode="false" sap:label="Id Trainingsgruppe" sap:creatable="false" sap:updatable="false" sap:filterable="false"/>\n <Property Name="Short" Type="Edm.String" MaxLength="12" sap:unicode="false" sap:label="K\xc3\xbcrzel Trainingsgruppe" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>\n <Property Name="Stext" Type="Edm.String" MaxLength="40" sap:unicode="false" sap:label="Bezeichnung Trainingsgruppe" sap:creatable="false" sap:updatable="false" sap:filterable="false"/>\n <Property Name="Begda" Type="Edm.DateTime" Precision="0" sap:unicode="false" sap:label="Beginndatum" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>\n <Property Name="Endda" Type="Edm.DateTime" Precision="0" sap:unicode="false" sap:label="Endedatum" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>\n <Property Name="Level" Type="Edm.Int32" sap:unicode="false" sap:label="Level" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>\n <Property Name="Parentid" Type="Edm.String" Nullable="false" MaxLength="8" sap:unicode="false" sap:label="ParentId" sap:creatable="false" sap:updatable="false" sap:filterable="false"/>\n <NavigationProperty Name="ChildGroupNodes" Relationship="Z_HR_LSO_WORKCENTER_SRV.GroupNodeToParent" FromRole="FromRole_GroupNodeToParent" ToRole="ToRole_GroupNodeToParent"/>\n <NavigationProperty Name="GroupToTrainingType" Relationship="Z_HR_LSO_WORKCENTER_SRV.GroupToTrainingType" FromRole="FromRole_GroupToTrainingType" ToRole="ToRole_GroupToTrainingType"/>\n</EntityType>\nRun Code Online (Sandbox Code Playgroud)\n我们正在使用 OData V2,因此不可能实现 FilterContains.All 过滤器。
\n是否甚至可以在前端过滤 sap.m.Tree 的子节点?
\n首先,自 1.44 以来,navigation不推荐使用 via 构建树层次结构。相反,SAP 建议利用元数据注释:
不推荐使用导航属性来构建层次结构,建议使用层次结构注释[...]。
完成向注释方法的迁移后,过滤客户端或服务器端。
ODataTreeBinding (或v2.ODataModel )operationMode的需要为。defaultOperationMode"Client"
调用时.filter,需要将FilterType"Control"作为第二个参数。
这是一个工作示例: https: //embed.plnkr.co/moTGOT
"Application"和。operationMode: "Server"在这种情况下,服务器需要$filter用现成的树结构来响应请求。这同样适用于兄弟节点和子节点的分页请求。