web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get record count of grid in Javascript (CRM 2013)

(0) ShareShare
ReportReport
Posted on by 2,601

I'm sure there must be a way of getting a count of the number of records being displayed in a grid but all the examples I've found don't work in CRM 2013?

Has anyone done this?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    jlattimer Profile Picture
    24,562 on at

    If you knew which FetchXml was used to create the grid, you could re-execute that query and and get the record count. 

    I don't believe there is a directly supported way to get the grid count otherwise but using jQuery you could do something like this:

    function GetSubGridCount2013() {
    	//SubGrid Name
    	var gridName = "accountopportunitiesgrid";
    	var count = $("#" + gridName + " .ms-crm-List-Data tbody tr").length;
    	alert(count);
    }
    

    Keep in mind that is totally unsupported.

  • CU21020959-0 Profile Picture
    2,601 on at

    Thanks for the replies.  I don't want to rerun the query again so using the jQuery was ideal.

  • Suggested answer
    iair007 Profile Picture
    55 on at

    if you want something supported you can do a retrieve of the the relationship that you need, every grid has a relationship, doing a retrieve you will get all the records that are related, these records are the ones that you see in the grid, this way you can count how many you have.

    I'm sure there must be a way of getting a count of the number of records being displayed in a grid but all the examples I've found don't work in CRM 2013?

    if you re interested, and don't know how to do it, let me know and I will make an example for you.

    good luck!

  • Community Member Profile Picture
    on at

    Hello everyone,

    I try to insert a fetchxml query into subgrid by javascript.

    the problem is that i cano't accsess to the sub grid, i get a null object.

    How can i do it in supporting way?

  • Powell360 Profile Picture
    on at

    i have a similar problem that I just can't explain, why would this happen?

    function calcServicePriceTotal() {

    alert("Start");//----------HERE

       if (document.getElementById("Services")) {

    alert("InsideIf"); //----------HERE

           var grid = document.getElementById("Services").control;

    alert("ThisFar?");//----------HERE

    alert(document.getElementById("Services"));

    alert(grid.Control.get_allRecordIds());

                          //Unable to get property 'get_allRecordIds' of undefined or null reference ----------CONSOLE OUTPUT

           var ids = grid.Control.get_allRecordIds()

    alert("ThisFar2?");//----------HERE

           for (i = 0; i < ids.length; i++) {

    alert("InsideFor");//----------HERE

              var cellValue = grid.control.getCellValue('iss_salesprice', ids[i]);

              var number = Number(cellValue.replace(/[^0-9\.]+/g, ""));

              sum = sum + number;

          }

          Xrm.Page.data.entity.attributes.get("ava_tempgrossvalue").setValue(sum);

      alert("Done");//----------HERE

       }

       else {

    alert("Else");//----------HERE

           setTimeout("calcServicePriceTotal();", 2500);

       }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans