Skip to Content
0

Initial Filter in Tree table SAPUI5

Jan 27, 2017 at 09:03 AM

532

avatar image

Hello,

Am trying to implement a tree table and fill data from a oData service and was successful in doing the same.

However am trying to apply a initial filter when the first odata service is triggered and tried the below code. But the filter parameters are not passed to the backend system.

Since its a tree table, the hierarchical level is always passed during the first call to Odata by default and would like to have my custom field to also be added in the filter.

var sUrl = "XXXXXXXXXXXXX";

            // set model on component
			this.getView().setModel(
                new ODataModel(sUrl, {
                	json: true,
                	batch: true
                })
            );	
			
 var oFilters = [ new sap.ui.model.Filter(
	          "OrderNumberID", "EQ", "XXXXX") ];
			
 var tab1 = this.getView().byId("TreeTableOpenOrders");
 tab1.getBinding("rows").filter(oFilters);  // No error but no data is passed
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Vikranth Reddy Jan 27, 2017 at 01:22 PM
0

Might help someone in the future.

The below bind row addition did the trick.

 var oFilters = [ new sap.ui.model.Filter("OrderNumberID", "EQ", "XXXXXXX") ];
			var tab1 = this.getView().byId(
			"TreeTableOpenOrders");			


            // set model on component
			this.getView().setModel(
                new ODataModel(sUrl, {
                	json: true,
                	batch: true
                })
            );	
			
			
			tab1.bindRows({
				path: "/OrderHeaders",
				filters: oFilters,
				parameters: {					
					countMode: "Inline",
					operationMode: "Server",					
					treeAnnotationProperties:  {
						hierarchyLevelFor : "HierLevel",
	                    hierarchyNodeFor : "OrderNumberID",
	                    hierarchyParentNodeFor : "SuperiorOrderNumber",
	                    hierarchyDrillStateFor : "DrillState"
					}
				}
			});
Share
10 |10000 characters needed characters left characters exceeded