如何在SAPUI5的树表中实现动态过滤功能?

时间:2018-01-25 01:15:07

标签: javascript sapui5 treetable

我正在尝试在SAPUI5树表中实现动态过滤器功能,但无法获得所需的结果。视图中的过滤器值正确传递给控制器​​,但过滤器未应用于表。以下是程序中使用的代码段。

  • 查看



<table:TreeTable id="treeTable" rows="{path:'/SalesOrderSet', parameters: {arrayNames:['SalesOrderItemSet']}}" 
		selectionMode="None" filter="sofilter">
		<table:columns type="Navigation">
			<table:Column showSortMenuEntry="true" sortProperty="Countid" filterProperty="SalesOrderId"
				defaultFilterOperator="Contains" >
				<table:template>
					<Text text="{SalesOrderId}"/>
				</table:template>
			</table:Column>
		</table:columns>
	</table:TreeTable>
&#13;
&#13;
&#13;

  • 控制器

&#13;
&#13;
sofilter: function(oEvt) {
	
	var filterValue = oEvt.getParameters().value;
	var filterOperator = oEvt.getParameters().column.mProperties.filterOperator;
	var filterProperty = oEvt.getParameters().column.mProperties.filterProperty;
	var oTreeTable = this.getView().byId("SalesOrderSet");
	var oBinding = oTreeTable.getBinding("rows");
	var filterArray = [];

	filterArray.push(new sap.ui.model.Filter({
		path: filterProperty,
		operator: sap.ui.model.FilterOperator.Contains,
		value1: filterValue
	}));
	oBinding.filter(filterArray);

}
&#13;
&#13;
&#13;

0 个答案:

没有答案