on 06-27-2016 12:36 PM
Hi Experts,
My requirement is to get the count of the status field for the odata "Service Request" and pass that count value to my table. Please suggest me how this can be accomplished in ui5.
On referring some blogs I am sure I have to use $count but not sure how to apply the same to a odata object field.
Thanks,
Srinivasan
Hi srinivasan,
Do you want to know the count of the list which you are getting from the odata?
If yes then you will the list of values in the success (data) there please place a breakpoint and check the data in the console,there you will get some list of objects.
if you check data.length you will get the count of the objects which you fetched....!
Thanks,
Deepak Raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi srinivasan,
Sorry for the wrong solution.
if you want to get the count of the particular field in the list of objects,then you need to read the complete data and then you have to pass your required fields in to one array then you can take the length of that array and you can pass it to the table.
I hope this will be helpful,if i am wrong please reply me back.
Thanks,
Deepak Raj.
Hi srinivasan,
Please take a look on the below piece of code:
var count = [ ] //defining an empty array
var data1 =model.getData().results; //this is the path of my records
for(var i=0;i<data1.length;i++){
if(data1[i].ContactTitle == "Owner"){
var obj = {}
obj.contacttitle = data1[i].ContactTitle;
count.push(obj); //pushing the record in to array
}//if
}//for
console.log(count.length); //here you can get the count
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.