Calculate number of rows in a model

edited March 7, 2017 in Questions
Hello again! I've a snippet which spits out a random selection of rows from a model but, to tidy it up, I need to know the total number of rows in a model (on the contact object).

I can't use a roll-up summary on the account as it doesn't work for the contact object so this needs to be done in javascript - is there a nice way of doing this using the API - or do I loop through the rows and count them?

Cheers!

Comments

  • J.J. 💎
    edited August 2, 2019
    Louis,

    We do have a way to get that count from the JS API. Each Skuid model contains an array named "data," which contains the rows within in the model. For instance, if your model is named "Contacts," you can get the number of rows as follows:
    skuid.model.getModel('Contacts').data.length
    Our skuid.model.Model api documentation contains the official write up. I hope that helps.
  • edited August 4, 2014
    Perfect, thanks guys.
  • J.J. 💎
    edited March 7, 2017
    No problem! I'm glad we could help.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!