cancel
Showing results for 
Search instead for 
Did you mean: 

Data binding not supported for sap.ui.model.filter

Former Member
0 Kudos

I just knew that using data binding with filter is not possible. But it is working when I write hard-coded word.

Is there an alternative way of using "{/lastName}" in the filter object?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Shahaleel,

You have to provide the filter value to get filter working while data binding. You can provide numerous number of filters and there is no restriction that you have to provide only one filter for one column. Consider, you wanted to filter "{/lastname}" with multiple filters, you can be able to do that. But, it is just you need to know, on what perspective the data filtering should work.


For example, you wanted to filter 'lastname' which starts with 'D' and contains letters 'ane' in the word.

Then you can say -



var oFilter1 = new sap.ui.model.Filter("lastname", sap.ui.model.FilterOperator.StartsWith, "D");

var oFilter2 = new sap.ui.model.Filter("lastname", sap.ui.model.FilterOperator.Contains, "ane");

//Data Binding Start

var oComboBox = new sap.m.ComboBox({

    items: {path:"/employee/contacts", template:oItemTemplate, filters:[oFilter1,oFilter2]}

});

For more info, check the aggregation binding document -

Aggregation Binding - User Interface Add-On for SAP NetWeaver - SAP Library

Regards,

Sai Vellanki.

Former Member
0 Kudos

I think you didn't get what I mean. I mean what if I want to search for something in the model, like below:

var oFilter1= new sap.ui.model.Filter("lastNameColumn", sap.ui.model.FilterOperator.Contains, "{/lastName}");

"{/lastName}" --> doesn't work but if I write the word hard-codded like "sd" it works !!!

santhu_gowdaz
Active Contributor
0 Kudos

var oView = this.getView();


var oFilter1= new sap.ui.model.Filter("lastNameColumn", sap.ui.model.FilterOperator.Contains,oView.getModel("ModelRef").getProperty('/lastName');

If no ModelRef then,

var oFilter1= new sap.ui.model.Filter("lastNameColumn", sap.ui.model.FilterOperator.Contains,oView.getModel().getProperty('/lastName');

Former Member
0 Kudos

can I use "this" in the view? it is not in the code completion

santhu_gowdaz
Active Contributor
0 Kudos

Sorry i thought you are doing this filter in controller.

How you are doing in view itself. It will break MVC architecture (UI5 follows MVC architecture ).

former_member182372
Active Contributor
0 Kudos

sap.ui.model.Filter oValue1 doesnt support data binding

retrieve the value from control directly or from model if it is bound

Answers (0)