Question:
I use your WinForms Grid Control and need to implement pagination. I need it since there are many records in the underlying database and I wish to implement a web inspired UI to avoid the necessity of scrolling the Grid. Is this a suitable solution?
Answer:
While Grid Control doesn't natively support pagination, it's possible to implement it. The solution depends on your requirements.
-
If your main requirement is to avoid the necessity of scrolling the Grid or you wish to implement a pager, use one of the following approaches:
- Bind the Grid to VirtualServerModeSource to implement paging: Virtual Paging module in the XtraGrid MainDemo. In this demo, we use LabelControl with hyperlinks implemented using HTML-inspired Text Formatting as a pager component. Note that this demo module is available starting with version 20.2. It's necessary to install Demo Center to run it.
- Implement pagination using the standard SQL server capabilities. Most SQL servers allow you to implement pagination over a given SQL query in the same manner as demonstrated in this StackOverflow discussion: What is the best way to paginate results in SQL Server. This approach is illustrated in the Grid Control - How to implement the pagination functionality using SQL queries example. Please take into account that the built-in sorting, grouping and filtering Grid functionality should be disabled and needs to be be implemented at the data source level.
P.S. In this example the standard Northwind database is used. If necessary, specify your connection string in the app.config file.
-
If you are looking for a way to avoid fetching all records at once and it's enough to load data by small portions in your scenario use one of the following approaches:
- Switch Grid in the Server Mode. To switch the Grid to Server Mode, bind it to one of the special data sources listed here: Server Mode Data Sources . Each data source supports one of the most popular data access technologies (Entity Framework, XPO, WFC) and has synchronous and asynchronous version. Please refer to the Large Data Sources: Server and Instant Feedback Modes help article to learn more about Server Mode sources;
- Use the Infinite Scrolling feature. This feature works when the Grid Control is bound to the VirtualServerModeSource data source. Implement pagination using the standard SQL server capabilities as shown in the What is the best way to paginate results in SQL Server thread and use VirtualServerModeSource as a bridge between GridControl and the SQL pagination logic. To make this approach work in your application, handle two main events:
– ConfigurationChanged to supply the initial batch of data
– MoreRows to supply a subsequent batch of data.
Please review our demo for a more detailed example of using VirtualServerModeSource to implement paging:
– Infinite Scrolling module in the XtraGrid MainDemo
– Virtual Paging module in the XtraGrid MainDemo
We would also be happy to hear any feedback. Feel free to leave a comment below and describe your complete scenario. It will make it clear for us why using pagination is vital in your particular case.
Also, see our quick-reference guide - it contains cheat sheets, best practices, and troubleshooting sections:
DevExpress WinForms Cheat Sheets
Search keywords:
Pagination, paging, page, pager, GridControl, Grid Control, Data Grid, WinForms, .NET
Is there an option for simply "local data paging" - this must be the simplest but I can't see it mentioned
I want to load all the data, so I definitely don't want to use VirtualServerModeSource or SQL feature and that also rules out all of option #2 above.
So I was looking just for is exactly what this javascript grid does - local pagination - and the performance does make a difference so I'm figuring this is worth doing in WinForms.
https://tabulator.info/docs/5.4/page#main-contents
Hello,
To avoid mixing multiple questions in one thread, I created a separate ticket on your behalf: Grid Control - Is there a build in pagination functionality. I will address it shortly.