Skip to Content
-2

To get particular field data from the oModel

Hi,

my data is in oModel.it contains many fields.i want to count the users from the model those who are active.there is field called active if it is X then the user is active else the user is not active. please help me with this

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jul 01, 2019 at 03:24 PM

    Hi Harish Kumar Bongula

    You may have JSON model created in your controller where you need count of Active Users as below and set it with your oData response.

    ojModel = new JSONModel();
    ojModel.setData(oData.results); //oData.results will be replaced by your response Object

    Now you have all your data in local JSON model, now you may loop through all data rows and increase count when you get "active === X".

    for (var k = 0; k < oData.results.length; k++) {
      IF(oData.results[k].active === "X"){
          totActive = totActive + 1;
      } 
    }
    

    You may use totActive variable to bind element or for further oprtation.

    Just to add the response string which you shared is not complete.. Hope you have shared part of your response string.

    Hope this Helps...

    Thanks-

    Abhishek

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.