Show conditionally grid pagination if total records is more than page size

Is there a way to conditionally show the pagination control based on TotalRecord > PageSize?

Currently the pagination control always shows regardless of how many records there are, we would like to hide this control if it's not necessary. Example below, since there's only one record, the pagination would not show. But for other records where data is more than the page size, then it should show.



3 Replies

VN Vignesh Natarajan Syncfusion Team March 4, 2020 06:42 AM UTC

Hi Juan,  
 
Thanks for contacting Syncfusion support.  
 
Query: “Is there a way to conditionally show the pagination control based on TotalRecord > PageSize? 
 
Yes we can achieve your requirement (to render pager based on a condition) by using property binding to AllowPaging property of the Grid. Refer the  below code example.  
 
<EjsGrid DataSource="@Orders" AllowPaging="@CanPaging">  
    <GridPageSettings PageSize="@Size"></GridPageSettings> 
. . . . . .. . . . .  
</EjsGrid> 
  
@code{ 
    public List<Order> Orders { getset; } 
    public int Size = 5; 
    public bool CanPaging { getset; } 
    protected override void OnInitialized() 
    { 
        Orders = Enumerable.Range(1, 20).Select(x => new Order() 
        { 
            OrderID = 1000 + x, 
. . . . .. . . .. . . 
        }).ToList(); 
        CanPaging = Orders.Count() > Size ? true : false; 
    } 
} 
 
   
For your convenience we have prepared a sample which can be downloaded from below  
 
 
Refer our UG documentation for your reference 
 

Kindly get back to us if above solution does not resolve your query.   
 
Regards, 
Vignesh Natarajan. 



JU Juan March 5, 2020 11:00 PM UTC

Thanks, this works.


VN Vignesh Natarajan Syncfusion Team March 6, 2020 03:12 AM UTC

Hi Juan,  

Thanks for the update.  

We are glad to hear that you have achieved your requirement using our solution.  

Kindly get back to us if you have further queries.  

Regards, 
Vignesh Natarajan.  


Loader.
Up arrow icon