Skip to Content

Initial Filter in Tree table SAPUI5

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
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 27, 2017 at 01:22 PM

    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"
    					}
    				}
    			});
    
    Add comment
    10|10000 characters needed characters exceeded