From 9afa1445890254e867dd172a36f42484aec8916b Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 28 Jun 2006 18:23:52 +0000 Subject: merge from 3.0 branch till 1208. --- .../pages/Controls/Samples/TPager/Sample1.page | 77 ++++++++++++++++++++ .../pages/Controls/Samples/TPager/Sample1.php | 82 ++++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php (limited to 'demos/quickstart/protected/pages/Controls/Samples') diff --git a/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page new file mode 100644 index 00000000..0d61f580 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.page @@ -0,0 +1,77 @@ + + +

TPager Sample

+

+The following sample displays three different pagers associated with a single TDataList control. The datalist control is enabled with custom paging, which allows it to read only one page of data each time. This is typical in DB-driven applications. +

+ +
+Go to page: + +
+ + + + +
Computer Parts
+
+ + +
+Total <%# $this->Parent->PageCount %> pages. +
+
+ + + + + + + + + + + + +
IDNameQuantityPrice
DataItem['id'] %> />DataItem['name'] %> />DataItem['quantity'] %> />$DataItem['price'] %> />
+
+ +
+ + +
+Choose page: + + +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php new file mode 100644 index 00000000..e5446f60 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TPager/Sample1.php @@ -0,0 +1,82 @@ +'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true), + array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true), + array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false), + array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false), + array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true), + array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true), + array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false), + array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true), + array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true), + array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false), + array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true), + array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true), + array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false), + array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true), + array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false), + array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false), + array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false), + ); + return array_slice($data,$offset,$limit); + } + + /** + * Determines which page of data to be displayed and + * populates the datalist with the fetched data. + */ + protected function populateData() + { + $offset=$this->DataList->CurrentPageIndex*$this->DataList->PageSize; + $limit=$this->DataList->PageSize; + if($offset+$limit>$this->DataList->VirtualItemCount) + $limit=$this->DataList->VirtualItemCount-$offset; + $data=$this->getData($offset,$limit); + $this->DataList->DataSource=$data; + $this->DataList->dataBind(); + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->DataList->VirtualItemCount=$this->DataItemCount; + $this->populateData(); + } + } + + /** + * Event handler to the OnPageIndexChanged event of pagers. + */ + public function pageChanged($sender,$param) + { + $this->DataList->CurrentPageIndex=$param->NewPageIndex; + $this->populateData(); + } +} + +?> \ No newline at end of file -- cgit v1.2.3