cancel
Showing results for 
Search instead for 
Did you mean: 

How can I Use filter in XML view?

ashwin_narayan
Participant
0 Kudos

Hi All,

    

          I been able to use filters in JS views but facing issues on how to use them in XML views. If anybody have any idea about the same.. please do share your valuable comments.

Thanks,

Ashwin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
ashwin_narayan
Participant
0 Kudos

Hi,

     Thanks for your fast reply. I been able to use filter like that way, but the I need t pass it dynamically. Lets suppose the value which entered in a field by the user should be content for value. Dynamic. Any idea about the?

Thanks,

Ashwin

Former Member
0 Kudos

Then you'll have to make use of your controller to do a filter based on dynamic values.

santhu_gowdaz
Active Contributor
0 Kudos

Hi Ashwin,

In view.xml create 1 input and change event,

in controller get that value and do filter like this below link,

SAPUI5: How to filter data with 2 or more values - Stack Overflow

Answers (2)

Answers (2)

Former Member
0 Kudos

hi Ashwin,

there is a filter tab in my master view like the below..

<subHeader>

  <Bar>

  <contentLeft>

  <SearchField search="handleSearch" width="100%">

  </SearchField>

  </contentLeft>

  </Bar>

  </subHeader>

i will call the function handleSearch in my controller in which i will write filter logic as below..

handleSearch : function (evt) {

  // create model filter

  var filters = [];

  var query = evt.getParameter("query");

  if (query && query.length > 0) {

  var filter = new sap.ui.model.Filter("SoId",

  sap.ui.model.FilterOperator.Contains, query);

  filters.push(filter);

  }

  // update list binding

  var list = this.getView().byId("list");

  var binding = list.getBinding("items");

  binding.filter(filters);

  },

In this SoId(which you want to filter) is some large number which i am entering in the search feild.. based on the entered number the number list in my master view will be filtered and updated..

ashwin_narayan
Participant
0 Kudos

Hey,

     This is not working for me. The scenario is I have a combobox which is populated,,, let's suppose with the name of an employee, for the combobox i have to use filter like his ID to get his name which i have to do dynamically. Then depending upon which name is selected in the combobox I have to populate the table with employee details, which is again a filter according to the value selected from the combobox...I have services for all these fumctionalities...achieved the same in JS view but facing issues in XML views... Any suggestions??

Thanks,

Ashwin

santhu_gowdaz
Active Contributor
0 Kudos

See this example,

SAPUI5 Explored