﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><pubDate>Tue, 30 Nov 2010 10:02:56 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;blockquote&gt;&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;Try to use the following code:&lt;/p&gt;&lt;pre&gt;function GetTotal()
{
   var grid = ISGetObject("WebGrid1");
   var getTotal = grid.TotalRows;
   var getChangesTotal = grid.RootTable.GetChangesCount();
   alert(getTotal &amp;#43; getChangesTotal);
}&lt;/pre&gt;&lt;p&gt;GetChangesCount() method is used to get the changes made in WebGrid. In this case, when you add new row, the total changes will be counted as well by using this method.&lt;/p&gt;&lt;p&gt;Therefore, you will get the total rows along with the added rows.&lt;/p&gt;&lt;p&gt;Hope this helps.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thank you.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This won't work either because the user can modify an existing row which would cause the count to be incremented by 1 too many (1 from the TotalRows and 1 from the GetChangesCount).&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I made a quick method that seems to work:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;pre&gt;function WebGrid_GetTotalRowCount(gridID) 
{
    try 
    {
        var grid = WebGrid_GetGrid(gridID);
        if (grid == null || grid.RootTable == null) { return 0; }
        
        // NOTE: This is done because Intersoft doesn't return the TotalRows accurately for a WebGrid using BatchUpdate
        var rowCount = 0;
        while (true) 
        {
            var row = grid.RootTable.GetRow(rowCount)
            if (row == null) { return rowCount; }
            rowCount&amp;#43;&amp;#43;;
        }
    }
    catch (ex) { ShowJSException(ex); }
}&lt;/pre&gt;
</description></item><item><title>How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><pubDate>Tue, 30 Nov 2010 04:37:00 GMT</pubDate><dc:creator>MarTin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Try to use the following code:&lt;/p&gt;&lt;pre&gt;function GetTotal()
{
   var grid = ISGetObject("WebGrid1");
   var getTotal = grid.TotalRows;
   var getChangesTotal = grid.RootTable.GetChangesCount();
   alert(getTotal &amp;#43; getChangesTotal);
}&lt;/pre&gt;
&lt;p&gt;GetChangesCount() method is used to get the changes made in WebGrid. In this case, when you add new row, the total changes will be counted as well by using this method.&lt;/p&gt;
&lt;p&gt;Therefore, you will get the total rows along with the added rows.&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;</description></item><item><title>How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><pubDate>Mon, 29 Nov 2010 13:32:52 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;blockquote&gt;&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;It is not designed for BatchUpdate scenario. It does not return the correct total because the added rows in your screenshot has not been saved in database yet.&lt;/p&gt;&lt;p&gt;Regards,&lt;br /&gt;Handy&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;So I assumed.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Do you have a workaround so I can get the correct # of rows that are visible in the grid?&lt;/p&gt;</description></item><item><title>How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><pubDate>Mon, 29 Nov 2010 13:31:33 GMT</pubDate><dc:creator>handy@intersoftpt.com</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;It is not designed for BatchUpdate scenario. It does not return the correct total because the added rows in your screenshot has not been saved in database yet.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Handy&lt;/p&gt;</description></item><item><title>How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><pubDate>Mon, 29 Nov 2010 10:01:39 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;blockquote&gt;&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;I use TotalRows method in order to obtain the total grid's rows, and the method also gets the total rows&amp;nbsp;after a record is added.&lt;/p&gt;&lt;pre&gt;function GetTotal()
{
   var grid = ISGetObject("WebGrid1");
   alert(grid.TotalRows);
}&lt;/pre&gt;&lt;p&gt;I have created a sample for your reference.&lt;/p&gt;&lt;p&gt;Hope this helps. Thank you.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Regards,&lt;/p&gt;&lt;p&gt;-Martin-&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Please read my initial post.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Here's a screen shot to show you that it doesn't return the correct # of rows.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><pubDate>Wed, 24 Nov 2010 02:06:19 GMT</pubDate><dc:creator>MarTin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I use TotalRows method in order to obtain the total grid's rows, and the method also gets the total rows after a record is added.&lt;/p&gt;&lt;pre&gt;function GetTotal()
{
   var grid = ISGetObject("WebGrid1");
   alert(grid.TotalRows);
}&lt;/pre&gt;

&lt;p&gt;I have created a sample for your reference.&lt;/p&gt;
&lt;p&gt;Hope this helps. Thank you.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;-Martin-&lt;/p&gt;</description></item><item><title>How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><pubDate>Tue, 23 Nov 2010 20:53:38 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;blockquote&gt;&lt;p&gt;var grid = ISGetObject("WebGrid1");&lt;br /&gt;var rowCount=grid.RootTable.GetRowsCount()//grid.TotalRows&lt;br /&gt;window.alert(rowCount); &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Did you even bother reading my post? &lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Anyhow, this does not return the total number of rows in the grid.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><pubDate>Tue, 23 Nov 2010 20:19:04 GMT</pubDate><dc:creator>qq397472251</dc:creator><description>&lt;p&gt;var grid = ISGetObject("WebGrid1");&lt;br /&gt;var rowCount=grid.RootTable.GetRowsCount()//grid.TotalRows&lt;br /&gt;window.alert(rowCount); &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>How to get the WebGrid's Total Row Count?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-to-get-the-WebGrids-Total-Row-Count/</link><pubDate>Tue, 23 Nov 2010 17:06:29 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;p&gt;var grid = ISGetObject("WebGrid1");&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;window.alert(grid.TotalLoadedRows); // Doesn't change after record has been added at client side.&lt;/p&gt;
&lt;p&gt;window.alert(grid.TotalRows);// Doesn't change after record has been added at client &lt;/p&gt;
&lt;p&gt;window.alert(grid.RootTable.&lt;span style="font-size: 13px"&gt;GetRowsCount&lt;/span&gt;());// Doesn't change after record has been added at client side&lt;/p&gt;
&lt;p&gt;window.alert(grid.RootTable.Rows); // Is null.&lt;/p&gt;
&lt;p&gt;window.alert(grid.RootTable.Rows.length); // Throws error.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;How do I get the TOTAL number of rows in the grid?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item></channel></rss>