summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-01-30 03:40:28 +0000
committerxue <>2006-01-30 03:40:28 +0000
commitf7b1db61531f9309dc9a1b9587449442a7ae5ed5 (patch)
treedba0fc0e23f841fef352ec3e8126b42d40d533d8
parent939f16aea32e1c200896fb59fab43098cfb0e135 (diff)
Added two repeater demos.
-rw-r--r--.gitattributes5
-rw-r--r--demos/quickstart/protected/pages/Controls/Repeater.page50
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page47
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php41
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page55
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php56
-rw-r--r--demos/quickstart/themes/PradoSoft/style.css2
7 files changed, 255 insertions, 1 deletions
diff --git a/.gitattributes b/.gitattributes
index 2b25391a..10ca1147 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -95,6 +95,7 @@ demos/quickstart/protected/pages/Controls/DataGrid.page -text
demos/quickstart/protected/pages/Controls/DataList.page -text
demos/quickstart/protected/pages/Controls/List.page -text
demos/quickstart/protected/pages/Controls/Overview.page -text
+demos/quickstart/protected/pages/Controls/Repeater.page -text
demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.page -text
demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php -text
demos/quickstart/protected/pages/Controls/Samples/TBulletedList/bullet.gif -text
@@ -138,6 +139,10 @@ demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.page -te
demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php -text
demos/quickstart/protected/pages/Controls/Samples/TRegularExpressionValidator/Home.page -text
demos/quickstart/protected/pages/Controls/Samples/TRegularExpressionValidator/Home.php -text
+demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page -text
+demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php -text
+demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page -text
+demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php -text
demos/quickstart/protected/pages/Controls/Samples/TRequiredFieldValidator/Home.page -text
demos/quickstart/protected/pages/Controls/Samples/TRequiredFieldValidator/Home.php -text
demos/quickstart/protected/pages/Controls/Samples/TTable/Home.page -text
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 @@
+<com:TContent ID="body" >
+
+<h1>TRepeater</h1>
+<p>
+TRepeater displays its content defined in templates repeatedly based on the given data specified by the <tt>DataSource</tt> or <tt>DataSourceID</tt> property. The repeated contents can be retrieved from the <tt>Items</tt> property. Each item is created by instantiating a template and each is a child control of the repeater. TRepeater provides the <tt>OnItemCommand</tt> event that serves as a central place to process all <tt>OnCommand</tt> events raised by child controls of the repeater items. And an <tt>OnItemCreated</tt> event is raised each time when a new item is created based on a template.
+</p>
+<p>
+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,
+</p>
+<ul>
+ <li><tt>HeaderTemplate</tt> - the template used for displaying content at the beginning of a repeater;</li>
+ <li><tt>FooterTemplate</tt> - the template used for displaying content at the end of a repeater;</li>
+ <li><tt>ItemTemplate</tt> - the template used for displaying every repeater item. If <tt>AlternatingItemTemplate</tt> is also defined, <tt>ItemTemplate</tt> will be used for displaying item 1, 3, 5, etc.</li>
+ <li><tt>AlternatingItemTemplate</tt> - the template used for displaying every alternating repeater item (i.e., item 2, 4, 6, etc.)</li>
+ <li><tt>SeparatorTemplate</tt> - the template used for displaying content between items.</li>
+</ul>
+<p>
+To populate data into the repeater items, set <tt>DataSource</tt> to a valid data object, such as array, <tt>TList</tt>, <tt>TMap</tt>, or a database table, and then call <tt>dataBind()</tt> for the repeater. That is,
+</p>
+<com:TTextHighlighter Language="php" CssClass="source">
+class MyPage extends TPage {
+ protected function onLoad($param) {
+ parent::onLoad($param);
+ if(!$this->IsPostBack) {
+ $this->Repeater->DataSource=$data;
+ $this->Repeater->dataBind();
+ }
+ }
+}
+</com:TTextHighlighter>
+<p>
+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.
+</p>
+<com:RunBar PagePath="Controls.Samples.TRepeater.Sample1" />
+<p>
+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 <tt>OnItemDataBound</tt> event of the outer repeater which is raised right after an outer repeater item completes databinding (therefore, the data is available).
+</p>
+<com:RunBar PagePath="Controls.Samples.TRepeater.Sample2" />
+<p>
+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.
+</p>
+<p>
+The <a href="../composer/index.php">PRADO component composer</a> 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 <tt>OnItemCommand</tt> event of repeater.
+</p>
+<p>
+See in the following yet another example showing how to use repeater to collect user inputs.
+</p>
+<com:RunBar PagePath="Controls.Samples.TRepeater.Sample3" />
+
+</com:TContent> \ 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 @@
+<com:TContent ID="body">
+
+<h1>TRepeater Sample 1</h1>
+
+<com:TRepeater ID="Repeater" >
+
+<prop:HeaderTemplate>
+<table cellpadding="2">
+<tr style="color:white;background-color:black">
+ <th>ID</th>
+ <th>Name</th>
+ <th>Quantity</th>
+ <th>Price</th>
+ <th>Imported</th>
+</tr>
+</prop:HeaderTemplate>
+
+<prop:ItemTemplate>
+<tr style="background-color:green">
+<td><%#$this->Parent->DataItem['id']%></td>
+<td><%#$this->Parent->DataItem['name']%></td>
+<td><%#$this->Parent->DataItem['quantity']%></td>
+<td><%#$this->Parent->DataItem['price']%></td>
+<td><%#$this->Parent->DataItem['imported']?'Yes':'No'%></td>
+</tr>
+</prop:ItemTemplate>
+
+<prop:AlternatingItemTemplate>
+<tr style="background-color:silver">
+<td><%#$this->Parent->DataItem['id']%></td>
+<td><%#$this->Parent->DataItem['name']%></td>
+<td><%#$this->Parent->DataItem['quantity']%></td>
+<td><%#$this->Parent->DataItem['price']%></td>
+<td><%#$this->Parent->DataItem['imported']?'Yes':'No'%></td>
+</tr>
+</prop:AlternatingItemTemplate>
+
+<prop:FooterTemplate>
+<tr style="color:white;background-color:black;text-align:center;">
+<td colspan="5">Computer Parts Inventory</td>
+</tr>
+</table>
+</prop:FooterTemplate>
+
+</com:TRepeater>
+
+</com:TContent> \ 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 @@
+<?php
+
+class Sample1 extends TPage
+{
+ protected function getData()
+ {
+ return 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),
+ );
+ }
+
+ 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 @@
+<com:TContent ID="body">
+
+<h1>TRepeater Sample 2</h1>
+
+<com:TRepeater ID="Repeater" OnItemDataBound="dataBindRepeater2">
+
+<prop:HeaderTemplate>
+<table cellspacing="1" style="border-collapse: collapse;border:1px solid silver">
+<tr style="color:white;background-color:black">
+<th colspan="2">Regional Personnel</th>
+</tr>
+</prop:HeaderTemplate>
+
+<prop:ItemTemplate>
+<tr>
+<td style="background-color:silver"><%#$this->Parent->DataItem %></td>
+<td>
+ <com:TRepeater ID="Repeater2">
+
+ <prop:HeaderTemplate>
+ <table cellspacing="1" style="border-collapse: collapse;border:1px solid silver">
+ </prop:HeaderTemplate>
+
+ <prop:ItemTemplate>
+ <tr style="background-color:#E6FFE6;">
+ <td style="width:70px"><%#$this->Parent->DataItem['name'] %></td>
+ <td style="width:20px"><%#$this->Parent->DataItem['age'] %></td>
+ <td style="width:150px"><%#$this->Parent->DataItem['position'] %></td>
+ </tr>
+ </prop:ItemTemplate>
+
+ <prop:AlternatingItemTemplate>
+ <tr style="background-color:#F0F0F0;">
+ <td style="width:70px"><%#$this->Parent->DataItem['name'] %></td>
+ <td style="width:20px"><%#$this->Parent->DataItem['age'] %></td>
+ <td style="width:150px"><%#$this->Parent->DataItem['position'] %></td>
+ </tr>
+ </prop:AlternatingItemTemplate>
+
+ <prop:FooterTemplate>
+ </table>
+ </prop:FooterTemplate>
+
+ </com:TRepeater>
+</td>
+</tr>
+</prop:ItemTemplate>
+
+<prop:FooterTemplate>
+</table>
+</prop:FooterTemplate>
+
+</com:TRepeater>
+
+</com:TContent> \ 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 @@
+<?php
+
+class Sample2 extends TPage
+{
+ protected function getMasterData()
+ {
+ return array('North','West','East','South');
+ }
+
+ protected function getDetailData($region)
+ {
+ static $data=array(
+ 'North'=>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 {