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

[Solved] show total number of records when not using paging

4 Answers 208 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
preet
Top achievements
Rank 1
preet asked on 13 Jun 2012, 04:45 AM
I dont want to use the paging, but still want to show the number of records in pager, which now only shows the refresh button. any help would be much appreciated

4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 13 Jun 2012, 08:59 AM
Hi Preet,

If  you have disabled the paging and you are using Ajax binding you can use the length of the data field provided by the Grid object to display the number of the records via the OnDataBound event.
e.g.
function onGridDataBound(e) {
    var recordsCount = $(this).data('tGrid').data.length;
    $('.t-status',this).after('<span>Number of records :'+ recordsCount +'</span>')
}

I hope this helps.

Kind regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
preet
Top achievements
Rank 1
answered on 13 Jun 2012, 11:52 PM
Thanks a lot for your reply. I found out another solution as well. I am setting the number of pages in OnComplete client event by accessing response.total.
So it is something like this.
  .OnComplete(  @<text> function(e){                                            
                                         addTotalRecordCounterToGridFooter("@gridId",e.response.total);
                                  }</text>
                           )        
                                          
0
Nagendra
Top achievements
Rank 1
answered on 21 Mar 2013, 03:58 PM
Hi,
i am using the same code as u mentioned,on page load its showing the proper record,but on filtering the grid,the the values are appending with previous one for example first time grid contain 50 records,it showing "Displaying:50 records" on filtering my grid contain 34 records at that  time it showing "Displaying:50 records Displaying:34 records" is there any solutions?
0
preet
Top achievements
Rank 1
answered on 21 Mar 2013, 10:37 PM
Hi Nagendra,
Here is the method:
function addTotalRecordCounterToGridFooter(gridId, numOfRecords) {
 $(
"#" + gridId + " .dummyFooter").remove();
 $(
"#" + gridId + " .t-grid-pager").append("<div class='dummyFooter' style='float:right; padding-right:12px;'>Total " + numOfRecords + " record(s) shown</div>");}


Hope this helps
Tags
Grid
Asked by
preet
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
preet
Top achievements
Rank 1
Nagendra
Top achievements
Rank 1
Share this question
or