From 5e8932fb41534dc0d06e76dae7b74cf47071f6e0 Mon Sep 17 00:00:00 2001 From: tof <> Date: Thu, 7 Feb 2008 10:32:04 +0000 Subject: Added TActivePager --- .../pages/ActiveControls/ActivePager.page | 41 ++++++++ .../protected/pages/ActiveControls/Home.page | 8 +- .../ActiveControls/Samples/TActivePager/Home.page | 103 +++++++++++++++++++++ .../ActiveControls/Samples/TActivePager/Home.php | 92 ++++++++++++++++++ .../pages/GettingStarted/NewFeatures.page | 5 + 5 files changed, 248 insertions(+), 1 deletion(-) create mode 100755 demos/quickstart/protected/pages/ActiveControls/ActivePager.page create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.php (limited to 'demos/quickstart/protected/pages') diff --git a/demos/quickstart/protected/pages/ActiveControls/ActivePager.page b/demos/quickstart/protected/pages/ActiveControls/ActivePager.page new file mode 100755 index 00000000..4589f381 --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/ActivePager.page @@ -0,0 +1,41 @@ + + +

TActivePager

+ + +

+TActivePager creates a pager that provides UI for end-users to interactively specify which page of data to be rendered in a TDataBoundControl-derived control, such as TDataList, TRepeater, TCheckBoxList, etc. +The target data-bound control is specified by the ControlToPaginate property, which must be the ID path of the target control reaching from the pager's naming container. The target-databound must be enclosed inside a TActivePanel in order +to be re-rendered during callback +

+ +

+Note, the target data-bound control must have its AllowPaging set to true. Otherwise the pager will be invisible. Also, in case when there is only one page of data available, the pager will also be invisible. +

+ +

+TActivePager can display one of the following three types of user interface, specified via its Mode property: +

+ +

+These user interfaces may be further customized by configuring the following properties +

+ + +

+TActivePager raises an OnPageIndexChanged event when an end-user interacts with it and specifies a new page (e.g. by clicking on a next page button that would lead to the next page.) Developers may write handlers to respond to this event and obtain the desired new page index from the event parameter's property NewPageIndex. Using this new page index, one can feed a new page of data to the associated data-bound control. +Additionnaly, TActivePager raises OnCallback after the OnPageIndexChanged. +

+ + + +
$Id: Pager.page 1650 2007-01-24 06:55:32Z wei $
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Home.page b/demos/quickstart/protected/pages/ActiveControls/Home.page index a7a0076a..4d0191e0 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Home.page @@ -70,7 +70,13 @@ TActiveButton control. See also the later part of the TActivePager + generates UI that allows users to interactively specify which page of + data to be displayed in a data-bound control. + +
  • * TActiveRadioButton represents a radiobutton on a Web page. diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page new file mode 100644 index 00000000..3153088d --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page @@ -0,0 +1,103 @@ + + +

    TActivePager 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: + + + Element.show('wait') + + + Element.hide('wait') + + + +
    + + + + +
    Computer Parts
    +
    + + +
    +Total <%# $this->Parent->PageCount %> pages. +
    +
    + + + + + + + + + + + + +
    IDNameQuantityPrice
    DataItem['id'] %> />DataItem['name'] %> />DataItem['quantity'] %> />$DataItem['price'] %> />
    +
    + +
    +
    + + + + Element.show('wait') + + + Element.hide('wait') + + +
    +Choose page: + + + Element.show('wait') + + + Element.hide('wait') + + + +
    $Id$
    diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.php new file mode 100644 index 00000000..40a867b5 --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.php @@ -0,0 +1,92 @@ +TActivePanel->render($param->NewWriter); + } + + /** + * Returns total number of data items. + * In DB-driven applications, this typically requires + * execution of an SQL statement with COUNT function. + * Here we simply return a constant number. + */ + protected function getDataItemCount() + { + return 19; + } + + /** + * Fetches a page of data. + * In DB-driven applications, this can be achieved by executing + * an SQL query with LIMIT clause. + */ + protected function getData($offset,$limit) + { + $data=array( + array('id'=>'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 diff --git a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page index 595bda00..3d9bc155 100644 --- a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page +++ b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page @@ -5,6 +5,11 @@

    This page summarizes the main new features that are introduced in each PRADO release.

    + +

    Version 3.1.2

    +

    Version 3.1.1