From bbb5ba2761529a2f477589623b2b76b10d6f8803 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 31 Jan 2006 21:27:51 +0000 Subject: Split TTable.php file into individual class files. Modified TRepeater demo 2. --- .../protected/pages/Controls/Repeater.page | 2 +- .../pages/Controls/Samples/TRepeater/Sample2.page | 64 +++++++++++----------- .../pages/Controls/Samples/TRepeater/Sample2.php | 21 +++++++ 3 files changed, 53 insertions(+), 34 deletions(-) (limited to 'demos/quickstart/protected/pages') diff --git a/demos/quickstart/protected/pages/Controls/Repeater.page b/demos/quickstart/protected/pages/Controls/Repeater.page index 9c21eaab..d8789dac 100644 --- a/demos/quickstart/protected/pages/Controls/Repeater.page +++ b/demos/quickstart/protected/pages/Controls/Repeater.page @@ -33,7 +33,7 @@ Normally, you only need to do this when the page containing the repeater is init

-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). +TRepeater can be used in more complex situations. As an example, we show in the following how to use nested repeaters, i.e., repeater in repeater. This is commonly seen in presenting master-detail data. 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. An OnItemDataBound event is raised each time an outer repeater item completes databinding. In the following example, we exploit another event of repeater called OnItemCreated, which is raised each time a repeater item (and its content) is newly created. We respond to this event by setting different background colors for repeater items to achieve alternating item background display. This saves us from writing an AlternatingItemTemplate for the repeaters.

diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page index dbfc7a18..bb78c35a 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page @@ -3,46 +3,44 @@

TRepeater Sample 2

+ OnItemDataBound="dataBindRepeater2" + OnItemCreated="repeaterItemCreated"> - - - - +
Regional Personnel
- + + <%#$this->NamingContainer->DataItem %> + diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php index a46a3327..96096a8a 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php @@ -51,6 +51,27 @@ class Sample2 extends TPage $item->Repeater2->dataBind(); } } + + public function repeaterItemCreated($sender,$param) + { + static $itemIndex=0; + $item=$param->Item; + if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem') + { + $item->Cell->BackColor=$itemIndex%2 ? "#6078BF" : "#809FFF"; + $item->Cell->ForeColor='white'; + } + $itemIndex++; + } + + public function repeater2ItemCreated($sender,$param) + { + static $itemIndex=0; + $item=$param->Item; + if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem') + $item->Row->BackColor=$itemIndex%2 ? "#BFCFFF" : "#E6ECFF"; + $itemIndex++; + } } ?> \ No newline at end of file -- cgit v1.2.3
<%#$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'] %>
- - -
+ + + + + + + + + + <%#$this->NamingContainer->DataItem['name'] %> + + + <%#$this->NamingContainer->DataItem['age'] %> + + + <%#$this->NamingContainer->DataItem['position'] %> + + + + + +
+ + +