cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass filter parameters to Get EntitySet from SAPUI5?

Jayakrishnan
Active Participant
0 Kudos

Hi Everyone,

We are working on SAPUI5 Application Development. In my application scenario i need to to pass some values from my View to Gateway OData Service, it should return the EntitySet value. in oModel.read, i can read only single data (Entity not EntitySet) right?

How to achieve this?

Thank you,

Regards,

JK.

Accepted Solutions (1)

Accepted Solutions (1)

rahulkumar_sankla
Participant

oModel.read can be used in both cases i.e. reading single entity or entityset

to read single entity, you need key of the entity. Below code might help to understand how that can be done:

var sPath = sEntitySetName + "(" + sKey + ")"; // sKey is the value of the key
oModel.read(sPath, {
success: function(data, response){
// your code to manipulate data received
}.bind(this)
error: function(response){
// error handling
}.bind(this)
});

use the code below for pass filter values. This will give array of the result set from backend

oModel.read(sPath, { // sPath - path of your Entityset
urlParameters:{
"$filter": "Field eq value"  // the "Field" is the field in the entity set to put a filter on and its value, 
                             //you can use eq, bt etc.
              }
success: function(data, response){
//your code for manipulation of the data received 
}.bind(this) // if you want to use the current controller instance within this function
error: function(response){
// for handling the error received
}.bind(this) // if you want to use the current controller instance within this function
});
Jayakrishnan
Active Participant
0 Kudos

Thank you, i will try this and update you

Answers (0)