Paging root rows

TreeGrid documentation

TreeGrid can automatically split root rows to pages and display them only on demand - when the page becomes visible due scroll.
The page names and links can be displayed in large vertical pager or in simple horizontal pager row.
For other possibilities of paging see paging tutorial.
See also examples in downloadable trial, for your server side script. For server paging see "Ajax table with server paging and export" example.

This paging type can page only root rows and cannot divide children of root rows to pages. So in tree this paging can become ineffective.
For paging child rows in tree use <Cfg ChildPaging/> and / or <Cfg ChildParts/>, see paging in tree.
The paging in tree is permitted by default - opposite to root paging.
<Cfg> int

Paging

[0]
Method of root paging used.
This paging is done only for root rows, it is the best for plain grids or trees with many root nodes.

0No paging
All rows are in one page, pager cannot be visible. All rows are rendered on start. This means slow start and fast use.
It is good for small grids, up to about 1000 rows in root.

1Show all
Pages are automatically created, but all are rendered on start.
For AllPages = 1 it renders all pages on start, but asynchronously and also pager components can be shown and used.
For AllPages = 0 is the same as 2 - Client paging.
It is good for medium grids, 250 - 1000 rows in root, to let users to easy navigate between parts in grid.
It can be used also to avoid browser "Slow script" message when rendering too many rows without paging.
You can also suppress the rendering message by setting <Lang><Text RenderProgressText=""/></Lang> and render all the pages on background. But it will slow the grid interaction responses.

2Client paging   (auto - fully done by TreeGrid)
Pages are automatically created.
For AllPages = 1 is page rendered only when it is visible in window by scrolling.
For AllPages = 0 is page rendered immediately, but it is visible only one page at a time and after switch to another page, the body is re-rendered.
It is good for large grids up to 10 000 rows. All functions still work offline, include sorting, filtering, grouping, searching and calculations.
The client paging does not require any server side support.

3Server paging   (auto fully done by TreeGrid)
Pages are created by server and TreeGrid downloads only page(s) being displayed.
The server is responsible for sending data for requested page and also for sorting, filtering, grouping, searching and aggregate calculation.
Calculations are still possible offline on client, but must be prepared on server.
It is good for very large grids, with more then 10 000 rows or for grids with special relations or grids need to be online.
The server paging requires a lot of your code on server side. To simplify this task you can use TreeGrid.dll/so.
For more information see server paging. If you are not able to do sorting, filtering or grouping on server and you still want to use these features, you can set OnePage attribute (and AllPages=0) to do them partially in actual page.
Server paging should not be used with Gantt chart, because Gantt is always calculated on client side from only loaded data.
<Cfg> bool

AllPages

[1]
Paging display mode
0Shows one page at a time and switches to pages only by pager click or by pressing PageUp / PageDown key.
1Shows all pages in grid at once and renders pages on demand, when they are displayed by scrolling.
<Cfg> int

PageLength

[20]
Average count of rows in page.
For client paging there are all pages created to contain this number of rows (except the last one).
For server paging it determines height of page - it is default value of <B Count> attribute.
Exact count of rows in pages can differ due to adding or deleting rows or in last incomplete page.
Every page must contain at least one row otherwise it is deleted. Exception is when grid does not contain any row, so it contains one empty page.
In TreeGrid server is this parameter used to set count of rows in page.
It is also possible to change it dynamically by API, but after change must be called grid.CreatePages(); grid.Render();
<Cfg> int

PageTime

[200]
How long (in ms) must be page visible (by scroll) before it loads data or renders (for AllPages=1).
new 6.0 <Cfg> int

MaxPages

[20]
Maximum rendered root pages in grid, only for AllPages = '1' and Paging >= 2.
When grid contains more rendered pages, the pages longer not accessed are cleared (only in HTML, pages data are not affected).
Used to not slow down the browser when too many HTML tags are displayed.
For large pages you can lower this value.
The actually displayed pages are never cleared.
Set it to 0 to disable clearing pages.
new 9.0 <Cfg> int

RemoveUnusedPages

[2]
If set to 0, it never removes unused root pages, child pages/parts and column pages.
If set to 2, it removes unused pages due MaxPages, MaxChildParts and MaxColPages.
If set to 3, it removes also data of unused root pages or child pages.
It removes only page or child page that does not contain changed rows.
new 12.0 <Cfg> int

RemoveUnusedFixed

[3]
If the fixed left and right column sections will be removed when removing unused row pages by MaxPages or MaxChildParts.
0 - none, 1 - left, 2 - right, 3 - both
new 9.3 <Cfg> int

RemoveChanged

[0]
How will behave changed rows on RemoveCollapsed or RemoveUnused.
0 - Don't remove changed rows and selected rows. If there is any such row, the removing is not done.
1 - Don't remove changed rows. If there is any such row, the removing is not done.
2 - Remove changed rows.
3 - Save changes and remove rows immediately.
4 - Save changes and wait for the server success response before removing rows.
new 6.7 <Cfg> int

PageWindowAdd

[0]
Increase this value to load and render the pages sooner than they are shown.
How many pixels before or after page can remain, before it is rendered or loaded.
By default (for 0) is page rendered after it is at least partially shown.
Remember, when scrolling grid, the pages are rendered after the scrolling finishes, regardless on this value.

Auto adding pages

Automatic adding new root pages on scroll

new 12.0 <Cfg> bool

AutoPages

[0]
If set, adds new root pages to the end of grid when it is scrolled down to the end of grid.
To use it, must be set also Paging to 1, 2 or 3 and AllPages to 1.
Printed, exported and uploaded are rows to last not empty row, see GetLastDataRow API method.
new 12.0 <Cfg> int

RemoveAutoPages

[0]
If the empty added pages will be automatically removed when the grid is scrolled up.
0 - never
1 - yes, the removed pages will be placed to RemovedPages and will be recreated from this stack. Useful to preserve the ids of the new rows and for Undo.
2 - yes, the removed pages will be thrown out. Useful for server paging or to remove all set attributes from the removed pages.
The page is removed only if all rows on the page and on all next pages are empty (values and EditAttrs).
new 12.0 API event void

OnPageAdded

(TGrid grid, TRow page)
Called after new page is added due AutoPages.
new 12.0 API event bool

OnRemoveAutoPage

(TGrid grid, TRow page)
Called before removing given page due RemoveAutoPages.
Return true to not remove this page and any of the previous pages.
new 12.0 API variable TRow

RemovedPages

The removed pages due RemoveAutoPages.
Can be set to null, to permanently remove these pages.
Their rows can be iterated by such loop: for(var r=grid.GetFirst(grid.RemovedPages);r;r=grid.GetNext(r)){ ... }
new 13.2 API method void

AddAutoPages

( )
Adds one new page. The page should be immediately shown otherwise it is later deleted.

API

API method int

GetPageNum

(TRow page)
Returns position of page (page index) inside body, from 0.
API method TRow

GetPage

(int num)
Returns root page inside that row is placed.
API method TRow

GetRowPage

(TRow row)
Returns root page inside that row is placed.
API method int

GetPagePos

(TRow row)
Returns row's position in its root page. It counts only visible rows.
In tree it counts all rows above the row inside the page.
API method TRow

PagePosToRow

(TRow page, int pos)
Returns row on given position on page. It counts only visible rows. It is only for loaded pages (State>2).
In tree it counts all visible expanded rows within the tree.
API method TRow

GetFPage

( )
Returns actual root page, if only one page is displayed at a time (if set <Cfg AllPages='0'/>
API method void

GoToPage

(TRow page)
Scrolls or moves to given page. To get page object by index use GetPage method.
Moves actual focus to appropriate row in the page (e.g. if the third row on the actual page was focused, the third row on the new page become focused).
API event bool

OnGoToPage

(TGrid grid, TRow page, int pagepos)
Called when grid displays another page. Return true to cancel change.
page is page (<B> tag) which will be changed to, pagepos is this page position inside body, from 0.
Called from GoToPage method.
It is called when user clicks page link on pager.
It is not called when a user scrolls or focuses to new page.
API method void

GoToNextPage

( )
Scrolls or moves to the next page. Moves actual focus to appropriate row in the page.
If you call this function from external button onclick, you should cancel the event by adding CancelEvent (event) to your handler or use StaticCursor='1' to preserve grid from loosing focus.
API method void

GoToPrevPage

( )
Scrolls or moves to previous page. Moves actual focus to appropriate row in the page.
If you call this function from external button onclick, you should cancel the event by adding CancelEvent (event) to your handler or use StaticCursor='1' to preserve grid from loosing focus.
API method void

ShowPages

( )
Starts loading and rendering displayed pages. Asynchronous.
Call this method if pages are not rendered automatically when you do some unusual changes in grid.
API method void

CreatePages

( )
Re-creates pages. After call must be called Render to re-render the grid.
Useful when PageLength was changed by API.
API method TRow

AddPage

(string name, string xml, int count)
Adds new page to the end of pages.
name is page name in pager, can contain HTML code.
xml is xml content for page, it can contain only rows like "<I A='10'/><I A='20'/>".
For server paging (Paging=3) xml can be null and data for page will be loaded from server, in this case count is supposed count of rows on page.
API event void

OnRenderPageStart

(TGrid grid, TRow row)
Called before rendering of the root page or child page started rendering.
When used child paging (<Cfg ChildPaging>), this event is fired before start of rendering children when a parent row is being expanded.
API event void

OnRenderPageFinish

(TGrid grid, TRow row)
Called after the root page or child page is fully rendered and ready.
When used child paging (<Cfg ChildPaging>), this event is fired after children are rendered when a parent row is being expanded.
API method void

RefreshPage

(TRow page, bool always = 0)
Re-renders page or row's children. For always = 1 re-renders the page also if it is not visible due scroll or expand state.
new 11.0 API method bool

RemovePage

(TRow page)
Removes the root page. All rows are physically removed according to RemoveChanged setting.
Returns false if it fails - it cannot remove page with focused cell or due RemoveChanged.
new 9.0 API event void

OnRemovePage

(TGrid grid, TRow page)
Called after removing data from page or child page, when set RemoveUnusedPages = 3.
new 9.3 API event int

OnRemoveChanged

(TGrid grid, TRow page)
Called if removing page containing some changed (or selected row for RemoveChanged==0)
For RemoveChanged==2 is called always.
Return new value for RemoveChanged to use - 1, 2, 3, 4
<Actions>

Repaint

Not attached to any event
Refreshes pages, when too many pages are displayed, the grid can slow down.
new 7.0 <Actions>

RenderPages

Attached to event OnClickButtonRepaint
Switches for Paging, ColPaging and ChildParts between value 1 and 2.
If any of the attribute is 2, it switches to 1 and renders all not yet rendered pages.
If all attributes are 1, it switches to 2 and clears all unused pages according to the MaxPages, MaxColPages and MaxChildParts settings.