Is there a simple way to remove the page control if there is only 1 page?

I know I can program it out but is there any method/property that I'm not seeing to stop the paging control from displaying when there is only one page?

5 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team February 12, 2021 08:43 AM UTC

Hi Mike, 
 
Greetings from Syncfusion support. 

Based on this scenario, we suggest you to apply styes for the pager to hide the pager element. In the below code we have raised a flag variable in DataBound event based on the records count to determine the number of pages in Grid. 

 
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" ...> 
    <GridEvents DataBound="DataBound" TValue="Order"></GridEvents> 
    ... 
</SfGrid> 
 
@if (flag) 
{ 
    <style> 
        .e-pager{ 
            display:none; 
        } 
    </style> 
} 
 
@code{ 
    SfGrid<Order> Grid; 
    public List<Order> Orders { getset; } 
    public bool flag = false; 
    public void DataBound() 
    { 
        if (Orders.Count() <= Grid.PageSettings.PageSize)  //compare total grid data count with pagesize value 
        { 
            flag = true; 
        } 
        else 
            flag = false; 
    } 


We are also attaching the sample for your reference, please download the sample from the link below, 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer

MC Mike Chafin February 12, 2021 10:52 AM UTC

Thanks for the code. I knew I could program it out but I was hoping there was an attribute on the <SfGrid> I missed. 

I'll ask for this feature on the feedback portal.


Thanks again,
 Mike
.


JP Jeevakanth Palaniappan Syncfusion Team February 15, 2021 01:14 PM UTC

Hi Mike, 

We have validated your query we have considered your requirement as a feature and logged the feature task “Need property to remove the pager when grid has only one page” for the same. Thank you for taking the time to request this improvement and helping us improve our product. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision and technological feasibility. It will be implemented in any of our upcoming releases. 
 
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.     
 
 
Until then we appreciate your patience. 
 
Regards, 
Jeevakanth SP. 




MC Mike Chafin February 23, 2021 05:47 PM UTC

I went to implement this and found that it would not work with the suggested codes. 

The issue is that if you're using the data manager with the query you may have a different number of rows. 

Using Grid.TotalItemCount works.

            if (Grid.TotalItemCount <= Grid.PageSettings.PageSize)  //compare total grid data count with pagesize value 
            {
                NoPaging = true;
            }
            else
                NoPaging = false;



JP Jeevakanth Palaniappan Syncfusion Team February 24, 2021 06:06 AM UTC

Hi Mike, 

Using Grid.TotalItemCount works:- 

Thanks for the update. Yes you can use the same to check the record count and compare with the pagesize. 
 
Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon