From 08bf73e5621cdc384db7c416e6e8b689123bb3a8 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 5 Feb 2006 03:48:45 +0000 Subject: Added paging example of TDataGrid. --- .../protected/pages/Controls/DataGrid2.page | 17 +++++- .../pages/Controls/Samples/TDataGrid/Sample5.page | 55 +++++++++++++++++++ .../pages/Controls/Samples/TDataGrid/Sample5.php | 63 ++++++++++++++++++++++ 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.php (limited to 'demos/quickstart/protected/pages') diff --git a/demos/quickstart/protected/pages/Controls/DataGrid2.page b/demos/quickstart/protected/pages/Controls/DataGrid2.page index a081fa46..4c295f5a 100644 --- a/demos/quickstart/protected/pages/Controls/DataGrid2.page +++ b/demos/quickstart/protected/pages/Controls/DataGrid2.page @@ -21,7 +21,22 @@ The following example turns the datagrid in

Paging

- +

+When dealing with large datasets, paging is helpful in reducing the page size and complexity. TDataGrid has an embedding paging feature. By setting AllowPaging to true, a pager is displayed automatically at the bottom of the datagrid. The pager can be further customized by setting PagerStyle, through which you can set pager visibility, mode, position, etc. +

+

+When users click on a pager button, TDataGrid raises OnPageIndexChanged event. Typically, the event handler is written as follows, +

+ +public function pageIndexChanged($sender,$param) { + $this->DataGrid->CurrentPageIndex=$param->NewPageIndex; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); +} + +

+The following example enables the paging functionality of the datagrid shown in Example 1. In this example, you can set various pager styles interactively to see how they affect the pager display. +

Custom Paging

diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.page b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.page new file mode 100644 index 00000000..17f2c5d4 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.page @@ -0,0 +1,55 @@ + + +

TDataGrid Sample 5

+

Paging

+ + + + + + + + + + + + + + + + +Next Page Text: +
+Prev Page Text: +
+ +
+ + + +Page Button Count: +
+ +
+ +
+ +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.php new file mode 100644 index 00000000..6d6d967c --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample5.php @@ -0,0 +1,63 @@ +DataGrid->CurrentPageIndex=$param->NewPageIndex; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function itemCreated($sender,$param) + { + $item=$param->Item; + if($item->ItemType==='Pager') + { + // prepend 'Page: ' to the pager + $item->Cells[0]->Controls->insertAt(0,'Page: '); + } + } + + public function changePagerPosition($sender,$param) + { + $top=$sender->Items[0]->Selected; + $bottom=$sender->Items[1]->Selected; + if($top && $bottom) + $position='TopAndBottom'; + else if($top) + $position='Top'; + else if($bottom) + $position='Bottom'; + else + $position=''; + if($position==='') + $this->DataGrid->PagerStyle->Visible=false; + else + { + $this->DataGrid->PagerStyle->Position=$position; + $this->DataGrid->PagerStyle->Visible=true; + } + } + + public function useNumericPager($sender,$param) + { + $this->DataGrid->PagerStyle->Mode='Numeric'; + $this->DataGrid->PagerStyle->PageButtonCount=$this->PageButtonCount->Text; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } + + public function useNextPrevPager($sender,$param) + { + $this->DataGrid->PagerStyle->Mode='NextPrev'; + $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text; + $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text; + $this->DataGrid->DataSource=$this->Data; + $this->DataGrid->dataBind(); + } +} + +?> \ No newline at end of file -- cgit v1.2.3