From f7b1db61531f9309dc9a1b9587449442a7ae5ed5 Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 30 Jan 2006 03:40:28 +0000 Subject: Added two repeater demos. --- .../protected/pages/Controls/Repeater.page | 50 +++++++++++++++++++ .../pages/Controls/Samples/TRepeater/Sample1.page | 47 ++++++++++++++++++ .../pages/Controls/Samples/TRepeater/Sample1.php | 41 ++++++++++++++++ .../pages/Controls/Samples/TRepeater/Sample2.page | 55 +++++++++++++++++++++ .../pages/Controls/Samples/TRepeater/Sample2.php | 56 ++++++++++++++++++++++ demos/quickstart/themes/PradoSoft/style.css | 2 +- 6 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 demos/quickstart/protected/pages/Controls/Repeater.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php (limited to 'demos') diff --git a/demos/quickstart/protected/pages/Controls/Repeater.page b/demos/quickstart/protected/pages/Controls/Repeater.page new file mode 100644 index 00000000..9c21eaab --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Repeater.page @@ -0,0 +1,50 @@ + + +

TRepeater

+

+TRepeater displays its content defined in templates repeatedly based on the given data specified by the DataSource or DataSourceID property. The repeated contents can be retrieved from the Items property. Each item is created by instantiating a template and each is a child control of the repeater. TRepeater provides the OnItemCommand event that serves as a central place to process all OnCommand events raised by child controls of the repeater items. And an OnItemCreated event is raised each time when a new item is created based on a template. +

+

+Like normal control templates, the repeater templates can contain static text, controls and special tags, which after instantiation, become child contents of the corresponding item. TRepeater defiens five templates for different purposes, +

+ +

+To populate data into the repeater items, set DataSource to a valid data object, such as array, TList, TMap, or a database table, and then call dataBind() for the repeater. That is, +

+ +class MyPage extends TPage { + protected function onLoad($param) { + parent::onLoad($param); + if(!$this->IsPostBack) { + $this->Repeater->DataSource=$data; + $this->Repeater->dataBind(); + } + } +} + +

+Normally, you only need to do this when the page containing the repeater is initially requested. In postbacks, TRepeater is smart enough to remember the previous state, i.e., contents populated with datasource information.The following sample displays tabular data using TRepeater. +

+ +

+TRepeater can be used in more complex situations. As an example, we show how to use nested repeaters, i.e., repeater in repeater. This is commonly seen in master-detail data presentation. To use a repeater within another repeater, for an item for the outer repeater is created, we need to set the detail data source for the inner repeater. This can be achieved by responding to the OnItemDataBound event of the outer repeater which is raised right after an outer repeater item completes databinding (therefore, the data is available). +

+ +

+Besides displaying data, TRepeater can also be used to collect data from users. Validation controls can be placed in TRepeater templates to verify that user inputs are valid. +

+

+The PRADO component composer demo is a good example of such usage. It uses a repeater to collect the component property and event definitions. Users can also delete or adjust the order of the properties and events, which is implemented by responding to the OnItemCommand event of repeater. +

+

+See in the following yet another example showing how to use repeater to collect user inputs. +

+ + +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page new file mode 100644 index 00000000..8e469fde --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page @@ -0,0 +1,47 @@ + + +

TRepeater Sample 1

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDNameQuantityPriceImported
<%#$this->Parent->DataItem['id']%><%#$this->Parent->DataItem['name']%><%#$this->Parent->DataItem['quantity']%><%#$this->Parent->DataItem['price']%><%#$this->Parent->DataItem['imported']?'Yes':'No'%>
<%#$this->Parent->DataItem['id']%><%#$this->Parent->DataItem['name']%><%#$this->Parent->DataItem['quantity']%><%#$this->Parent->DataItem['price']%><%#$this->Parent->DataItem['imported']?'Yes':'No'%>
Computer Parts Inventory
+ + +
+ +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php new file mode 100644 index 00000000..c88b8d9a --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php @@ -0,0 +1,41 @@ +'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), + ); + } + + protected function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->Repeater->DataSource=$this->getData(); + $this->Repeater->dataBind(); + } + } +} + +?> \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page new file mode 100644 index 00000000..174f132c --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page @@ -0,0 +1,55 @@ + + +

TRepeater Sample 2

+ + + + + + + + + + + + + + + + + + +
Regional Personnel
<%#$this->Parent->DataItem %> + + + + + + + + + + + + + + + + + + + + + + + +
<%#$this->Parent->DataItem['name'] %><%#$this->Parent->DataItem['age'] %><%#$this->Parent->DataItem['position'] %>
<%#$this->Parent->DataItem['name'] %><%#$this->Parent->DataItem['age'] %><%#$this->Parent->DataItem['position'] %>
+ + +
+
+ + +
+ +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php new file mode 100644 index 00000000..59d01f57 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php @@ -0,0 +1,56 @@ +array( + array('name'=>'John','age'=>30,'position'=>'Program Manager'), + array('name'=>'Edward','age'=>35,'position'=>'Developer'), + array('name'=>'Walter','age'=>28,'position'=>'Developer'), + ), + 'West'=>array( + array('name'=>'Cary','age'=>31,'position'=>'Senior Manager'), + array('name'=>'Ted','age'=>25,'position'=>'Developer'), + array('name'=>'Kevin','age'=>28,'position'=>'Developer'), + ), + 'East'=>array( + array('name'=>'Shawn','age'=>30,'position'=>'Sales Manager'), + array('name'=>'Larry','age'=>28,'position'=>'Document Writer'), + ), + 'South'=>array( + array('name'=>'King','age'=>30,'position'=>'Program Manager'), + array('name'=>'Carter','age'=>22,'position'=>'Developer'), + ), + ); + return $data[$region]; + } + + protected function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->Repeater->DataSource=$this->getMasterData(); + $this->Repeater->dataBind(); + } + } + + public function dataBindRepeater2($sender,$param) + { + $item=$param->Item; + if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem') + { + $item->Repeater2->DataSource=$this->getDetailData($item->DataItem); + $item->Repeater2->dataBind(); + } + } +} + +?> \ No newline at end of file diff --git a/demos/quickstart/themes/PradoSoft/style.css b/demos/quickstart/themes/PradoSoft/style.css index dbfc64d3..e054d05a 100644 --- a/demos/quickstart/themes/PradoSoft/style.css +++ b/demos/quickstart/themes/PradoSoft/style.css @@ -173,7 +173,7 @@ a .runbar { - margin: 2em 0 3em 0; + margin: 1em 0 1em 0; } .runbar a:link, .runbar a:visited { -- cgit v1.2.3