This is a migrated thread and some comments may be shown as answers.

How do I get the total count ?

1 Answer 214 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 31 Jul 2019, 08:04 PM

Hi !

How do I get the total record count of the RadDataPager at any given time ?

The count on load, after a sort, after a filter...etc.

The end goal being (displayed under my RadDataGrid):

"Total Number of Records: 1536"

or even better, based on a PageSize=100 :

"Displaying 300-400 (of 1536 records)"

 

...I'm assuming you guys would have added this functionality a long time ago - maybe within the RadDataGrid itself, after the Paging is wired in ?!!?

1 Answer, 1 is accepted

Sort by
0
Barry
Top achievements
Rank 1
answered on 01 Aug 2019, 09:07 PM

This seems to do the trick:

                string recordText = "0";
                var page = EventSummaryDataPager as RadDataPager;
                int result1 = (page.PageIndex * page.PageSize) + 1;
                int result2 = (page.PageSize * (page.PageIndex + 1));

                int remainder = 0;

                if (events.Count != events.PageSize)
                    remainder = events.Count;
        
                if (page.ItemCount > 0) { 

                    if (remainder == 0) { 
                        recordText = String.Format("{0} - {1} (of {2}) ", result1, result2, page.ItemCount);
                    }
                    else {
                        int final = (result1 + remainder) - 1;
                        recordText = String.Format("{0} - {1} (of {2}) ", result1, final, page.ItemCount);
                    }

                    //UPDATE THE TEXTBLOCK
                    EventSummaryGridItemCount.Text = recordText;
                }

Tags
DataPager
Asked by
Barry
Top achievements
Rank 1
Answers by
Barry
Top achievements
Rank 1
Share this question
or