summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes26
-rw-r--r--HISTORY3
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Home.page71
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.page17
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php41
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.page65
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php91
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.page83
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php190
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.page55
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php21
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.page62
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php73
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.page26
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.php56
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.php28
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.tpl34
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.page47
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.php41
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.page58
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.php79
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.page104
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.php84
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.page27
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.php43
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.page18
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.php52
-rw-r--r--framework/Web/UI/ActiveControls/TActiveDataGrid.php630
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRepeater.php105
29 files changed, 2203 insertions, 27 deletions
diff --git a/.gitattributes b/.gitattributes
index 1399f881..c3670138 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1305,10 +1305,34 @@ demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.pag
demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.php -text
demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page -text
demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.php -text
demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page -text
demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php -text
demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/hello_world.gif -text
demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.tpl -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.php -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.php -text
demos/quickstart/protected/pages/ActiveControls/Samples/TAutoComplete/Home.page -text
demos/quickstart/protected/pages/ActiveControls/Samples/TAutoComplete/Home.php -text
demos/quickstart/protected/pages/ActiveControls/Samples/config.xml -text
@@ -2649,6 +2673,7 @@ framework/Web/TUrlMapping.php -text
framework/Web/UI/ActiveControls/TActiveButton.php -text
framework/Web/UI/ActiveControls/TActiveControlAdapter.php -text
framework/Web/UI/ActiveControls/TActiveCustomValidator.php -text
+framework/Web/UI/ActiveControls/TActiveDataGrid.php -text
framework/Web/UI/ActiveControls/TActiveDataList.php -text
framework/Web/UI/ActiveControls/TActiveHiddenField.php -text
framework/Web/UI/ActiveControls/TActiveLabel.php -text
@@ -2656,6 +2681,7 @@ framework/Web/UI/ActiveControls/TActivePageAdapter.php -text
framework/Web/UI/ActiveControls/TActivePager.php -text
framework/Web/UI/ActiveControls/TActivePanel.php -text
framework/Web/UI/ActiveControls/TActiveRatingList.php -text
+framework/Web/UI/ActiveControls/TActiveRepeater.php -text
framework/Web/UI/ActiveControls/TActiveTextBox.php -text
framework/Web/UI/ActiveControls/TAutoComplete.php -text
framework/Web/UI/ActiveControls/TBaseActiveControl.php -text
diff --git a/HISTORY b/HISTORY
index 36f98829..eb321d59 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3,6 +3,9 @@ NEW: Issue#83 - PHP configuration style (Carl)
NEW: Port Yii's DBO (Christophe)
NEW: Port Yii's ActiveRecords (Daniel + Robin)
NEW: Port Yii's Models and Behaviors (Daniel + Robin)
+NEW: Add TActiveDataList (Marcosanobre, Robin)
+NEW: Add TActiveRepeater (LCS Team, Christophe)
+NEW: Add TActiveDatagrid (LCS Team, Christophe)
Version 3.1.6 to be released
BUG: Issue#98 - Missing file in quickstart demo (Chrisotphe)
diff --git a/demos/quickstart/protected/pages/ActiveControls/Home.page b/demos/quickstart/protected/pages/ActiveControls/Home.page
index 49855980..4897226c 100644
--- a/demos/quickstart/protected/pages/ActiveControls/Home.page
+++ b/demos/quickstart/protected/pages/ActiveControls/Home.page
@@ -70,12 +70,12 @@ TActiveButton</a> control. See also the later part of the <a href="?page=Tutoria
it is displayed as a &lt;div&gt; element. The panel's contents
can be replaced during a callback request.
</li>
-
- <li>
- <a href="?page=ActiveControls.ActivePager">TActivePager</a>
- generates UI that allows users to interactively specify which page of
- data to be displayed in a data-bound control.
- </li>
+
+ <li>
+ <a href="?page=ActiveControls.ActivePager">TActivePager</a>
+ generates UI that allows users to interactively specify which page of
+ data to be displayed in a data-bound control.
+ </li>
<li>
* <a href="?page=ActiveControls.ActiveRadioButton">TActiveRadioButton</a>
@@ -125,6 +125,23 @@ TActiveButton</a> control. See also the later part of the <a href="?page=Tutoria
TActiveRadioButtonList displays a group of radiobuttons. Each radio button
can perform a callback request.
</li>
+
+ <li>
+ * <a href="?page=ActiveControls.ActiveRepeater">TActiveRepeater</a>
+ is the active counterpart of TRepeater, which can be updated during a callback request
+ </li>
+
+ <li>
+ * <a href="?page=ActiveControls.ActiveDataList">TActiveDataList</a>
+ is the active counterpart of TDataList
+ </li>
+
+
+ <li>
+ * <a href="?page=ActiveControls.ActiveDataList">TActiveDataGrid</a>
+ is the active counterpart of TDataGrid
+ </li>
+
</ul>
<h2 id="128034">Extended Active Controls</h2>
@@ -160,12 +177,12 @@ TActiveButton</a> control. See also the later part of the <a href="?page=Tutoria
* <a href="?page=ActiveControls.ValueTriggeredCallback">TValueTriggeredCallback</a>
monitors (using a timer) an attribute of an HTML element and triggers a callback request
when the attribute value changes.
- </li>
-
- <li>
- <a href="?page=ActiveControls.DragDrop">TDropContainer & TDraggable</a> represents drag and drop containers.
- The former will make its child controls "draggable" while the latter will raise a callback when a draggable
- control is dropped on it.
+ </li>
+
+ <li>
+ <a href="?page=ActiveControls.DragDrop">TDropContainer & TDraggable</a> represents drag and drop containers.
+ The former will make its child controls "draggable" while the latter will raise a callback when a draggable
+ control is dropped on it.
</li>
</ul>
@@ -316,20 +333,20 @@ if Javascript was disabled on the client's browser.</p>
<a href="?page=ActiveControls.ValueTriggeredCallback">TValueTriggeredCallback</a>
</td>
<td>Yes</td><td>No</td>
- </tr>
-
- <tr><td>
- <a href="?page=ActiveControls.DragDrop">TDropContainer</a>
- </td>
- <td>Yes</td><td>No</td>
- </tr>
-
- <tr><td>
- <a href="?page=ActiveControls.DragDrop">TDraggable</a>
- </td>
- <td>No</td><td>No</td>
- </tr>
-
+ </tr>
+
+ <tr><td>
+ <a href="?page=ActiveControls.DragDrop">TDropContainer</a>
+ </td>
+ <td>Yes</td><td>No</td>
+ </tr>
+
+ <tr><td>
+ <a href="?page=ActiveControls.DragDrop">TDraggable</a>
+ </td>
+ <td>No</td><td>No</td>
+ </tr>
+
</table>
@@ -377,4 +394,4 @@ realize the active controls.</p>
</ul>
-<div class="last-modified">$Id$</div></com:TContent>
+<div class="last-modified">$Id$</div></com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.page
new file mode 100644
index 00000000..db537902
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.page
@@ -0,0 +1,17 @@
+<com:TContent ID="body">
+
+<h1>TActiveDataGrid Sample 1</h1>
+<h2>Using Automatically Generated Columns</h2>
+
+<com:TActiveDataGrid
+ ID="DataGrid"
+ EnableViewState="false"
+ CellPadding="2"
+ HeaderStyle.BackColor="black"
+ HeaderStyle.ForeColor="white"
+ ItemStyle.BackColor="#BFCFFF"
+ ItemStyle.Font.Italic="true"
+ AlternatingItemStyle.BackColor="#E6ECFF"
+ />
+
+<div class="last-modified">$Id: Sample1.page 1650 2007-01-24 06:55:32Z wei $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php
new file mode 100644
index 00000000..ec78006b
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/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),
+ );
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.page
new file mode 100644
index 00000000..851fd157
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.page
@@ -0,0 +1,65 @@
+<com:TContent ID="body">
+
+<h1>TActiveDataGrid Sample 2</h1>
+<h2>Using Manually Specified Columns</h2>
+
+<com:TActiveDataGrid
+ Width="700px"
+ CellPadding="2"
+ ID="DataGrid"
+ AutoGenerateColumns="false"
+ HeaderStyle.BackColor="black"
+ HeaderStyle.ForeColor="white"
+ ItemStyle.BackColor="#BFCFFF"
+ ItemStyle.Font.Italic="true"
+ AlternatingItemStyle.BackColor="#E6ECFF">
+
+ <com:THyperLinkColumn
+ HeaderText="Book Title"
+ DataTextField="title"
+ DataNavigateUrlField="ISBN"
+ DataNavigateUrlFormatString="http://www.amazon.com/gp/product/%s"
+ Target="_blank"
+ />
+ <com:TBoundColumn
+ HeaderText="Publisher"
+ DataField="publisher"
+ />
+ <com:TBoundColumn
+ ItemStyle.HorizontalAlign="Right"
+ ItemStyle.Wrap="false"
+ ItemStyle.Font.Italic="false"
+ ItemStyle.ForeColor="green"
+ HeaderText="Price"
+ DataField="price"
+ DataFormatString="$%.2f"
+ />
+ <com:TCheckBoxColumn
+ HeaderText="In-stock"
+ HeaderStyle.Wrap="false"
+ DataField="instock"
+ />
+ <com:TTemplateColumn>
+ <prop:HeaderTemplate>Rating</prop:HeaderTemplate>
+ <prop:ItemTemplate>
+ <img src="images/star<%#$this->Parent->DataItem['rating']%>.gif" alt="" />
+ </prop:ItemTemplate>
+ </com:TTemplateColumn>
+</com:TActiveDataGrid>
+
+<com:TPanel GroupingText="Column Visibility" Width="200px">
+
+<com:TActiveCheckBoxList
+ AutoPostBack="true"
+ OnSelectedIndexChanged="toggleColumnVisibility"
+ OnCallback="redraw">
+ <com:TListItem Text="Book Title" Selected="true" />
+ <com:TListItem Text="Publisher" Selected="true" />
+ <com:TListItem Text="Price" Selected="true" />
+ <com:TListItem Text="In-stock" Selected="true" />
+ <com:TListItem Text="Rating" Selected="true" />
+</com:TActiveCheckBoxList>
+
+</com:TPanel>
+
+<div class="last-modified">$Id: Sample2.page 1650 2007-01-24 06:55:32Z wei $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php
new file mode 100644
index 00000000..486d9d51
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php
@@ -0,0 +1,91 @@
+<?php
+
+class Sample2 extends TPage
+{
+ protected function getData()
+ {
+ return array(
+ array(
+ 'ISBN'=>'0596007124',
+ 'title'=>'Head First Design Patterns',
+ 'publisher'=>'O\'Reilly Media, Inc.',
+ 'price'=>29.67,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201633612',
+ 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.04,
+ 'instock'=>true,
+ 'rating'=>5,
+ ),
+ array(
+ 'ISBN'=>'0321247140',
+ 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>37.49,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201485672',
+ 'title'=>'Refactoring: Improving the Design of Existing Code',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.14,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
+ array(
+ 'ISBN'=>'0321213351',
+ 'title'=>'Refactoring to Patterns',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>38.49,
+ 'instock'=>true,
+ 'rating'=>2,
+ ),
+ array(
+ 'ISBN'=>'0735619670',
+ 'title'=>'Code Complete',
+ 'publisher'=>'Microsoft Press',
+ 'price'=>32.99,
+ 'instock'=>false,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0321278658',
+ 'title'=>'Extreme Programming Explained : Embrace Change',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>34.99,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
+ );
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+ }
+
+ public function toggleColumnVisibility($sender,$param)
+ {
+ foreach($this->DataGrid->Columns as $index=>$column)
+ $column->Visible=$sender->Items[$index]->Selected;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function redraw($sender,$param)
+ {
+ $this->DataGrid->render($param->NewWriter);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.page
new file mode 100644
index 00000000..94aa95fe
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.page
@@ -0,0 +1,83 @@
+<com:TContent ID="body">
+
+<h1>TActiveDataGrid Sample 3</h1>
+<h2>Interacting with TActiveDataGrid</h2>
+
+<com:TActiveDataGrid
+ Width="800px"
+ CellPadding="2"
+ ID="DataGrid"
+ DataKeyField="ISBN"
+ AutoGenerateColumns="false"
+ HeaderStyle.BackColor="black"
+ HeaderStyle.ForeColor="white"
+ ItemStyle.BackColor="#BFCFFF"
+ ItemStyle.Font.Italic="true"
+ AlternatingItemStyle.BackColor="#E6ECFF"
+ EditItemStyle.BackColor="lightyellow"
+ OnItemCreated="itemCreated"
+ OnEditCommand="editItem"
+ OnUpdateCommand="saveItem"
+ OnCancelCommand="cancelItem"
+ OnDeleteCommand="deleteItem"
+ >
+
+ <com:TActiveBoundColumn
+ ID="BookTitleColumn"
+ HeaderText="Book Title"
+ HeaderStyle.Width="400px"
+ DataField="title"
+ />
+ <com:TActiveBoundColumn
+ ID="PublisherColumn"
+ HeaderText="Publisher"
+ HeaderStyle.Width="150px"
+ DataField="publisher"
+ />
+ <com:TActiveBoundColumn
+ ID="PriceColumn"
+ ItemStyle.HorizontalAlign="Right"
+ ItemStyle.Wrap="false"
+ ItemStyle.Font.Italic="false"
+ ItemStyle.ForeColor="green"
+ HeaderText="Price"
+ HeaderStyle.Width="70px"
+ DataField="price"
+ DataFormatString="$%.2f"
+ />
+ <com:TActiveCheckBoxColumn
+ ID="InStockColumn"
+ HeaderText="In-stock"
+ DataField="instock"
+ />
+ <com:TActiveDropDownListColumn
+ ID="RatingColumn"
+ HeaderText="Rating"
+ DataTextField="rating"
+ >
+ <prop:DataTextFormatString><img src="images/star%s.gif" alt="" /></prop:DataTextFormatString>
+ <com:TListItem Value="1" />
+ <com:TListItem Value="2" />
+ <com:TListItem Value="3" />
+ <com:TListItem Value="4" />
+ <com:TListItem Value="5" />
+ </com:TActiveDropDownListColumn>
+ <com:TActiveEditCommandColumn
+ HeaderText="Edit"
+ HeaderStyle.Width="100px"
+ UpdateText="Save"
+ ItemStyle.HorizontalAlign="Center"
+ ItemStyle.Font.Italic="false"
+ />
+ <com:TActiveButtonColumn
+ ID="DeleteColumn"
+ HeaderText="Delete"
+ HeaderStyle.Width="50px"
+ ItemStyle.HorizontalAlign="Center"
+ ItemStyle.Font.Italic="false"
+ Text="Delete"
+ CommandName="delete"
+ />
+</com:TActiveDataGrid>
+
+<div class="last-modified">$Id: Sample3.page 1650 2007-01-24 06:55:32Z wei $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php
new file mode 100644
index 00000000..bb18f36b
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php
@@ -0,0 +1,190 @@
+<?php
+
+class Sample3 extends TPage
+{
+ private $_data=null;
+
+ protected function getData()
+ {
+ if($this->_data===null)
+ $this->loadData();
+ return $this->_data;
+ }
+
+ protected function loadData()
+ {
+ // We use viewstate keep track of data.
+ // In real applications, data should come from database using an SQL SELECT statement.
+ // In the following tabular data, field 'ISBN' is the primary key.
+ // All update and delete operations should come with an 'id' value in order to go through.
+ if(($this->_data=$this->getViewState('Data',null))===null)
+ {
+ $this->_data=array(
+ array(
+ 'ISBN'=>'0596007124',
+ 'title'=>'Head First Design Patterns',
+ 'publisher'=>'O\'Reilly Media, Inc.',
+ 'price'=>29.67,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201633612',
+ 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.04,
+ 'instock'=>true,
+ 'rating'=>5,
+ ),
+ array(
+ 'ISBN'=>'0321247140',
+ 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>37.49,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201485672',
+ 'title'=>'Refactoring: Improving the Design of Existing Code',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.14,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
+ array(
+ 'ISBN'=>'0321213351',
+ 'title'=>'Refactoring to Patterns',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>38.49,
+ 'instock'=>true,
+ 'rating'=>2,
+ ),
+ array(
+ 'ISBN'=>'0735619670',
+ 'title'=>'Code Complete',
+ 'publisher'=>'Microsoft Press',
+ 'price'=>32.99,
+ 'instock'=>false,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0321278658 ',
+ 'title'=>'Extreme Programming Explained : Embrace Change',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>34.99,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
+ );
+ $this->saveData();
+ }
+ }
+
+ protected function saveData()
+ {
+ $this->setViewState('Data',$this->_data);
+ }
+
+ protected function updateBook($isbn,$title,$publisher,$price,$instock,$rating)
+ {
+ // In real applications, data should be saved to database using an SQL UPDATE statement
+ if($this->_data===null)
+ $this->loadData();
+ $updateRow=null;
+ foreach($this->_data as $index=>$row)
+ if($row['ISBN']===$isbn)
+ $updateRow=&$this->_data[$index];
+ if($updateRow!==null)
+ {
+ $updateRow['title']=$title;
+ $updateRow['publisher']=$publisher;
+ $updateRow['price']=TPropertyValue::ensureFloat(ltrim($price,'$'));
+ $updateRow['instock']=TPropertyValue::ensureBoolean($instock);
+ $updateRow['rating']=TPropertyValue::ensureInteger($rating);
+ $this->saveData();
+ }
+ }
+
+ protected function deleteBook($isbn)
+ {
+ // In real applications, data should be saved to database using an SQL DELETE statement
+ if($this->_data===null)
+ $this->loadData();
+ $deleteIndex=-1;
+ foreach($this->_data as $index=>$row)
+ if($row['ISBN']===$isbn)
+ $deleteIndex=$index;
+ if($deleteIndex>=0)
+ {
+ unset($this->_data[$deleteIndex]);
+ $this->saveData();
+ }
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+ }
+
+ public function itemCreated($sender,$param)
+ {
+ $item=$param->Item;
+ if($item->ItemType==='EditItem')
+ {
+ // set column width of textboxes
+ $item->BookTitleColumn->TextBox->Columns=40;
+ $item->PriceColumn->TextBox->Columns=5;
+ }
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem' || $item->ItemType==='EditItem')
+ {
+ // add an aleart dialog to delete buttons
+ $item->DeleteColumn->Button->Attributes->onclick='if(!confirm(\'Are you sure?\')) return false;';
+ }
+ }
+
+ public function editItem($sender,$param)
+ {
+ $this->DataGrid->EditItemIndex=$param->Item->ItemIndex;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function saveItem($sender,$param)
+ {
+ $item=$param->Item;
+ $this->updateBook(
+ $this->DataGrid->DataKeys[$item->ItemIndex], // ISBN
+ $item->BookTitleColumn->TextBox->Text, // title
+ $item->PublisherColumn->TextBox->Text, // publisher
+ $item->PriceColumn->TextBox->Text, // price
+ $item->InStockColumn->CheckBox->Checked, // instock
+ $item->RatingColumn->DropDownList->SelectedValue // rating
+ );
+ $this->DataGrid->EditItemIndex=-1;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function cancelItem($sender,$param)
+ {
+ $this->DataGrid->EditItemIndex=-1;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function deleteItem($sender,$param)
+ {
+ $this->deleteBook($this->DataGrid->DataKeys[$param->Item->ItemIndex]);
+ $this->DataGrid->EditItemIndex=-1;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.page
new file mode 100644
index 00000000..76a2bb86
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.page
@@ -0,0 +1,55 @@
+<com:TContent ID="body">
+
+<h1>TActiveDataGrid Sample 4</h1>
+<h2>Sorting with TActiveDataGrid</h2>
+
+<com:TActiveDataGrid
+ Width="700px"
+ CellPadding="2"
+ ID="DataGrid"
+ AutoGenerateColumns="false"
+ HeaderStyle.BackColor="black"
+ HeaderStyle.ForeColor="white"
+ ItemStyle.BackColor="#BFCFFF"
+ ItemStyle.Font.Italic="true"
+ AlternatingItemStyle.BackColor="#E6ECFF"
+ AllowSorting="true"
+ OnSortCommand="sortDataGrid">
+
+ <com:TActiveHyperLinkColumn
+ SortExpression="title"
+ HeaderText="Book Title"
+ DataTextField="title"
+ DataNavigateUrlField="ISBN"
+ DataNavigateUrlFormatString="http://www.amazon.com/gp/product/%s"
+ Target="_blank"
+ />
+ <com:TActiveBoundColumn
+ SortExpression="publisher"
+ HeaderText="Publisher"
+ DataField="publisher"
+ />
+ <com:TActiveBoundColumn
+ SortExpression="price"
+ ItemStyle.HorizontalAlign="Right"
+ ItemStyle.Wrap="false"
+ ItemStyle.Font.Italic="false"
+ ItemStyle.ForeColor="green"
+ HeaderText="Price"
+ DataField="price"
+ DataFormatString="$%.2f"
+ />
+ <com:TActiveCheckBoxColumn
+ SortExpression="instock"
+ HeaderText="In-stock"
+ HeaderStyle.Wrap="false"
+ DataField="instock"
+ />
+ <com:TActiveTemplateColumn HeaderText="Rating" SortExpression="rating">
+ <prop:ItemTemplate>
+ <img src="images/star<%#$this->NamingContainer->DataItem['rating']%>.gif" alt="" />
+ </prop:ItemTemplate>
+ </com:TActiveTemplateColumn>
+</com:TActiveDataGrid>
+
+<div class="last-modified">$Id: Sample4.page 1650 2007-01-24 06:55:32Z wei $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php
new file mode 100644
index 00000000..80a9c8bc
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php
@@ -0,0 +1,21 @@
+<?php
+
+Prado::using('Application.pages.ActiveControls.Samples.TActiveDataGrid.Sample2');
+
+class Sample4 extends Sample2
+{
+ protected function sortData($data,$key)
+ {
+ $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}');
+ usort($data,$compare) ;
+ return $data ;
+ }
+
+ public function sorTActiveDataGrid($sender,$param)
+ {
+ $this->DataGrid->DataSource=$this->sortData($this->Data,$param->SortExpression);
+ $this->DataGrid->dataBind();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.page
new file mode 100644
index 00000000..a912c0d3
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.page
@@ -0,0 +1,62 @@
+<com:TContent ID="body">
+
+<h1>TActiveDataGrid Sample 5</h1>
+<h2>Paging</h2>
+
+<div style="width:500px">
+<com:TActiveDataGrid
+ ID="DataGrid"
+ AllowPaging="true"
+ PageSize="5"
+ PagerStyle.Mode="Numeric"
+ PagerStyle.HorizontalAlign="Right"
+ Width="100%"
+ CellPadding="2"
+ HeaderStyle.BackColor="black"
+ HeaderStyle.ForeColor="white"
+ ItemStyle.BackColor="#BFCFFF"
+ ItemStyle.Font.Italic="true"
+ AlternatingItemStyle.BackColor="#E6ECFF"
+ OnPageIndexChanged="changePage"
+ OnPagerCreated="pagerCreated"
+ />
+</div>
+
+<com:TActivePanel GroupingText="Pager Visibility" Width="300px">
+
+<com:TActiveCheckBoxList
+ AutoPostBack="true"
+ RepeatColumns="2"
+ OnSelectedIndexChanged="changePagerPosition" OnCallback="redrawDG">
+ <com:TListItem Text="Top" />
+ <com:TListItem Text="Bottom" Selected="true" />
+</com:TActiveCheckBoxList>
+
+</com:TActivePanel>
+
+<com:TActivePanel GroupingText="Pager Mode" Width="300px">
+
+<com:TActivePanel GroupingText="NextPrev Pager" Width="300px">
+
+Next Page Text:
+<com:TActiveTextBox ID="NextPageText" Text="Next" /><br/>
+Prev Page Text:
+<com:TActiveTextBox ID="PrevPageText" Text="Prev" /><br/>
+<com:TActiveButton Text="Submit" OnClick="useNextPrevPager" OnCallback="redrawDG"/>
+</com:TActivePanel>
+
+<com:TActivePanel GroupingText="Numeric Pager" Width="300px">
+
+Page Button Count:
+<com:TActiveTextBox ID="PageButtonCount" Text="5" /><br/>
+<com:TActiveButton Text="Submit" OnClick="useNumericPager" OnCallback="redrawDG"/>
+</com:TActivePanel>
+
+<com:TActivePanel GroupingText="Page Size" Width="300px">
+<com:TActiveTextBox ID="PageSize" Text="5" /><br/>
+<com:TActiveButton Text="Submit" OnClick="changePageSize" OnCallback="redrawDG"/>
+</com:TActivePanel>
+
+</com:TActivePanel>
+
+<div class="last-modified">$Id: Sample5.page 1650 2007-01-24 06:55:32Z wei $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php
new file mode 100644
index 00000000..37347c7b
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php
@@ -0,0 +1,73 @@
+<?php
+
+Prado::using('Application.pages.ActiveControls.Samples.TActiveDataGrid.Sample1');
+
+class Sample5 extends Sample1
+{
+ public function changePage($sender,$param)
+ {
+ $this->DataGrid->CurrentPageIndex=$param->NewPageIndex;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function pagerCreated($sender,$param)
+ {
+ $param->Pager->Controls->insertAt(0,'Page: ');
+ }
+
+ public function changePagerPosition($sender,$param)
+ {
+ $top=$sender->Items[0]->Selected;
+ $bottom=$sender->Items[1]->Selected;
+ if($top && $bottom)
+ $position='TopAndBottom';
+ else if($top)
+ $position='Top';
+ else if($bottom)
+ $position='Bottom';
+ else
+ $position='';
+ if($position==='')
+ $this->DataGrid->PagerStyle->Visible=false;
+ else
+ {
+ $this->DataGrid->PagerStyle->Position=$position;
+ $this->DataGrid->PagerStyle->Visible=true;
+ }
+ }
+
+ public function useNumericPager($sender,$param)
+ {
+ $this->DataGrid->PagerStyle->Mode='Numeric';
+ $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text;
+ $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text;
+ $this->DataGrid->PagerStyle->PageButtonCount=$this->PageButtonCount->Text;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function useNextPrevPager($sender,$param)
+ {
+ $this->DataGrid->PagerStyle->Mode='NextPrev';
+ $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text;
+ $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function changePageSize($sender,$param)
+ {
+ $this->DataGrid->PageSize=TPropertyValue::ensureInteger($this->PageSize->Text);
+ $this->DataGrid->CurrentPageIndex=0;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function redrawDG ($sender, $param)
+ {
+ $this->DataGrid->render($param->newWriter);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.page
new file mode 100644
index 00000000..dd3fcdf8
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.page
@@ -0,0 +1,26 @@
+<com:TContent ID="body">
+
+<h1>TActiveDataGrid Sample 6</h1>
+<h2>Custom Paging</h2>
+
+<div style="width:500px">
+<com:TActiveDataGrid
+ ID="DataGrid"
+ Width="100%"
+ AllowPaging="true"
+ AllowCustomPaging="true"
+ VirtualItemCount="19"
+ PageSize="5"
+ PagerStyle.Mode="Numeric"
+ PagerStyle.HorizontalAlign="Right"
+ CellPadding="2"
+ HeaderStyle.BackColor="black"
+ HeaderStyle.ForeColor="white"
+ ItemStyle.BackColor="#BFCFFF"
+ ItemStyle.Font.Italic="true"
+ AlternatingItemStyle.BackColor="#E6ECFF"
+ OnPageIndexChanged="changePage"
+ />
+</div>
+
+<div class="last-modified">$Id: Sample6.page 1650 2007-01-24 06:55:32Z wei $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.php
new file mode 100644
index 00000000..7b217e24
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.php
@@ -0,0 +1,56 @@
+<?php
+
+Prado::using('Application.pages.ActiveControls.Samples.TActiveDataGrid.Sample1');
+
+class Sample6 extends Sample1
+{
+ /**
+ * Returns a subset of data.
+ * In MySQL database, this can be replaced by LIMIT clause
+ * in an SQL select statement.
+ * @param integer the starting index of the row
+ * @param integer number of rows to be returned
+ * @return array subset of data
+ */
+ protected function getDataRows($offset,$rows)
+ {
+ $data=$this->getData();
+ $page=array();
+ for($i=0;$i<$rows;++$i)
+ {
+ if($offset+$i<$this->getRowCount())
+ $page[$i]=$data[$offset+$i];
+ }
+ return $page;
+ }
+
+ /**
+ * Returns total number of data rows.
+ * In real DB applications, this may be replaced by an SQL select
+ * query with count().
+ * @return integer total number of data rows
+ */
+ protected function getRowCount()
+ {
+ return 19;
+ }
+
+ public function onLoad($param)
+ {
+ if(!$this->IsPostBack)
+ {
+ $this->DataGrid->DataSource=$this->getDataRows(0,$this->DataGrid->PageSize);
+ $this->DataGrid->dataBind();
+ }
+ }
+
+ public function changePage($sender,$param)
+ {
+ $this->DataGrid->CurrentPageIndex=$param->NewPageIndex;
+ $offset=$param->NewPageIndex*$this->DataGrid->PageSize;
+ $this->DataGrid->DataSource=$this->getDataRows($offset,$this->DataGrid->PageSize);
+ $this->DataGrid->dataBind();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.php
new file mode 100644
index 00000000..40d1841e
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.php
@@ -0,0 +1,28 @@
+<?php
+
+class RegionDisplay extends TRepeaterItemRenderer
+{
+ /**
+ * This method is invoked when the data is being bound
+ * to the parent repeater.
+ * At this time, the <b>Data</b> is available which
+ * refers to the data row associated with the parent repeater item.
+ */
+ public function onDataBinding($param)
+ {
+ parent::onDataBinding($param);
+ $this->Repeater->DataSource=$this->Data['detail'];
+ $this->Repeater->dataBind();
+ }
+
+ public function itemCreated($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
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.tpl b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.tpl
new file mode 100644
index 00000000..0ab9b164
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.tpl
@@ -0,0 +1,34 @@
+<tr>
+<com:TTableCell ID="Cell"
+ ForeColor="white"
+ BackColor="<%# $this->ItemIndex%2 ? '#6078BF' : '#809FFF' %>"
+ Text="<%#$this->Data['name'] %>"
+ />
+<td>
+
+<com:TActiveRepeater ID="Repeater" OnItemCreated="itemCreated">
+<prop:HeaderTemplate>
+<table cellspacing="1">
+</prop:HeaderTemplate>
+
+<prop:ItemTemplate>
+<com:TTableRow ID="Row">
+ <com:TTableCell Width="70px">
+ <%#$this->Data['name'] %>
+ </com:TTableCell>
+ <com:TTableCell Width="20">
+ <%#$this->Data['age'] %>
+ </com:TTableCell>
+ <com:TTableCell Width="150px">
+ <%#$this->Data['position'] %>
+ </com:TTableCell>
+</com:TTableRow>
+</prop:ItemTemplate>
+
+<prop:FooterTemplate>
+</table>
+</prop:FooterTemplate>
+</com:TActiveRepeater>
+
+</td>
+</tr>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.page
new file mode 100644
index 00000000..ec740487
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.page
@@ -0,0 +1,47 @@
+<com:TContent ID="body">
+
+<h1>TActiveRepeater Sample 1</h1>
+
+<com:TActiveRepeater ID="Repeater" EnableViewState="false">
+
+<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:#BFCFFF">
+<td><%#$this->Data['id']%></td>
+<td><%#$this->Data['name']%></td>
+<td><%#$this->Data['quantity']%></td>
+<td><%#$this->Data['price']%></td>
+<td><%#$this->Data['imported']?'Yes':'No'%></td>
+</tr>
+</prop:ItemTemplate>
+
+<prop:AlternatingItemTemplate>
+<tr style="background-color:#E6ECFF">
+<td><%#$this->Data['id']%></td>
+<td><%#$this->Data['name']%></td>
+<td><%#$this->Data['quantity']%></td>
+<td><%#$this->Data['price']%></td>
+<td><%#$this->Data['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:TActiveRepeater>
+
+<div class="last-modified">$Id: Sample1.page 1688 2007-02-09 22:48:31Z xue $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.php
new file mode 100644
index 00000000..905a3b8d
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/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),
+ );
+ }
+
+ public 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/ActiveControls/Samples/TActiveRepeater/Sample2.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.page
new file mode 100644
index 00000000..bdb6ec2f
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.page
@@ -0,0 +1,58 @@
+<com:TContent ID="body">
+
+<h1>TActiveRepeater Sample 2</h1>
+
+<com:TActiveRepeater ID="Repeater"
+ EnableViewState="false"
+ OnItemDataBound="dataBindRepeater2"
+ OnItemCreated="repeaterItemCreated">
+
+<prop:HeaderTemplate>
+<table cellspacing="1" style="border:1px solid silver">
+</prop:HeaderTemplate>
+
+<prop:ItemTemplate>
+<tr>
+<com:TTableCell ID="Cell">
+ <%#$this->Data %>
+</com:TTableCell>
+<td>
+ <com:TActiveRepeater
+ ID="Repeater2"
+ EnableViewState="false"
+ OnItemCreated="Page.repeater2ItemCreated">
+
+ <prop:HeaderTemplate>
+ <table cellspacing="1">
+ </prop:HeaderTemplate>
+
+ <prop:ItemTemplate>
+ <com:TTableRow ID="Row">
+ <com:TTableCell Width="70px">
+ <%#$this->Data['name'] %>
+ </com:TTableCell>
+ <com:TTableCell Width="20">
+ <%#$this->Data['age'] %>
+ </com:TTableCell>
+ <com:TTableCell Width="150px">
+ <%#$this->Data['position'] %>
+ </com:TTableCell>
+ </com:TTableRow>
+ </prop:ItemTemplate>
+
+ <prop:FooterTemplate>
+ </table>
+ </prop:FooterTemplate>
+
+ </com:TActiveRepeater>
+</td>
+</tr>
+</prop:ItemTemplate>
+
+<prop:FooterTemplate>
+</table>
+</prop:FooterTemplate>
+
+</com:TActiveRepeater>
+
+<div class="last-modified">$Id: Sample2.page 1688 2007-02-09 22:48:31Z xue $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.php
new file mode 100644
index 00000000..e84580a2
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.php
@@ -0,0 +1,79 @@
+<?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];
+ }
+
+ public 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();
+ }
+ }
+
+ 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
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.page
new file mode 100644
index 00000000..1ea4e9dc
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.page
@@ -0,0 +1,104 @@
+<com:TContent ID="body">
+
+<h1>TActiveRepeater Sample 3</h1>
+
+<p>
+The following example allows users to modify the existing tabular data using a <tt>TActiveRepeater</tt>. Two validators are used in the repeater to ensure the validity of user inputs. One is to ensure product names are not empty, the other ensures product prices are valid numeric format. After clicking on the <tt>save</tt> button, the input data is displayed in a table at the bottom of the page.
+</p>
+
+<table>
+<tr>
+ <th>Name</th>
+ <th>Category</th>
+ <th>Price</th>
+ <th>Imported</th>
+</tr>
+<com:TRepeater ID="Repeater" OnItemDataBound="repeaterDataBound">
+<prop:ItemTemplate>
+<tr>
+ <td>
+ <com:TActiveTextBox
+ ID="ProductName"
+ Text=<%#$this->Data['name']%>
+ AutoPostBack="true"
+ OnTextChanged="Page.saveInput"
+ OnCallback="Page.renderRepeater2"/>
+ </td>
+ <td>
+ <com:TActiveDropDownList
+ ID="ProductCategory"
+ AutoPostBack="true"
+ OnSelectedIndexChanged="Page.saveInput"
+ OnCallback="Page.renderRepeater2"/>
+ </td>
+ <td>
+ <com:TActiveTextBox
+ ID="ProductPrice"
+ Columns="7"
+ Text=<%#$this->Data['price']%>
+ AutoPostBack="true"
+ OnTextChanged="Page.saveInput"
+ OnCallback="Page.renderRepeater2"/>
+ </td>
+ <td>
+ <com:TActiveCheckBox
+ ID="ProductImported"
+ Checked=<%#$this->Data['imported']%>
+ AutoPostBack="true"
+ OnCheckedChanged="Page.saveInput"
+ OnCallback="Page.renderRepeater2"/>
+ <com:TRequiredFieldValidator
+ ControlToValidate="ProductName"
+ ErrorMessage="Product name cannot be empty."
+ Display="Dynamic" />
+ <com:TRegularExpressionValidator
+ ControlToValidate="ProductPrice"
+ RegularExpression="\d+(\.\d{1,2})?"
+ ErrorMessage="Product price must be in the format of ddd.dd"
+ Display="Dynamic" />
+ </td>
+</tr>
+</prop:ItemTemplate>
+</com:TRepeater>
+</table>
+
+<div>
+<com:TActiveButton Text="Save" OnClick="saveInput" OnCallback="renderRepeater2"/>
+</div>
+
+<com:TSafeHtml>
+<com:TActiveRepeater ID="Repeater2" EnableViewState="false" >
+
+<prop:HeaderTemplate>
+<table cellpadding="2">
+<tr style="color:white;background-color:black">
+ <th>ID</th>
+ <th>Name</th>
+ <th>Category</th>
+ <th>Price</th>
+ <th>Imported</th>
+</tr>
+</prop:HeaderTemplate>
+
+<prop:ItemTemplate>
+<tr style="<%# 'background-color:' . ($this->ItemIndex%2 ? '#BFCFFF' : '#E6ECFF') %>">
+<td><%#$this->Data['id']%></td>
+<td><%#$this->Data['name']%></td>
+<td><%#$this->Data['category']%></td>
+<td><%#$this->Data['price']%></td>
+<td><%#$this->Data['imported']?'Yes':'No'%></td>
+</tr>
+</prop:ItemTemplate>
+
+<prop:FooterTemplate>
+<tr style="color:white;background-color:black;text-align:center;">
+<td colspan="5">Computer Parts Inventory</td>
+</tr>
+</table>
+</prop:FooterTemplate>
+
+</com:TActiveRepeater>
+
+</com:TSafeHtml>
+
+<div class="last-modified">$Id: Sample3.page 1688 2007-02-09 22:48:31Z xue $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.php
new file mode 100644
index 00000000..4cb5fafd
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.php
@@ -0,0 +1,84 @@
+<?php
+
+class Sample3 extends TPage
+{
+ protected function getProducts()
+ {
+ return array(
+ array('id'=>'ITN001','name'=>'Motherboard','category'=>'CAT004','price'=>100.00,'imported'=>true),
+ array('id'=>'ITN002','name'=>'CPU','category'=>'CAT004','price'=>150.00,'imported'=>true),
+ array('id'=>'ITN003','name'=>'Harddrive','category'=>'CAT003','price'=>80.00,'imported'=>true),
+ array('id'=>'ITN006','name'=>'Keyboard','category'=>'CAT002','price'=>20.00,'imported'=>false),
+ array('id'=>'ITN008','name'=>'CDRW drive','category'=>'CAT003','price'=>40.00,'imported'=>true),
+ array('id'=>'ITN009','name'=>'Cooling fan','category'=>'CAT001','price'=>10.00,'imported'=>false),
+ array('id'=>'ITN012','name'=>'Floppy drive','category'=>'CAT003','price'=>12.00,'imported'=>false),
+ array('id'=>'ITN013','name'=>'CD drive','category'=>'CAT003','price'=>20.00,'imported'=>true),
+ array('id'=>'ITN014','name'=>'DVD drive','category'=>'CAT003','price'=>80.00,'imported'=>true),
+ array('id'=>'ITN015','name'=>'Mouse pad','category'=>'CAT001','price'=>5.00,'imported'=>false),
+ );
+ }
+
+ protected function getCategories()
+ {
+ return array(
+ array('id'=>'CAT001','name'=>'Accessories'),
+ array('id'=>'CAT002','name'=>'Input Devices'),
+ array('id'=>'CAT003','name'=>'Drives'),
+ array('id'=>'CAT004','name'=>'Barebone'),
+ );
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack && ! $this->IsCallBack)
+ {
+ $this->Repeater->DataSource=$this->Products;
+ $this->Repeater->dataBind();
+ }
+ }
+
+ public function repeaterDataBound($sender,$param)
+ {
+ $item=$param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ {
+ $item->ProductCategory->DataSource=$this->Categories;
+ $item->ProductCategory->DataTextField='name';
+ $item->ProductCategory->DataValueField='id';
+ $item->ProductCategory->dataBind();
+ $item->ProductCategory->SelectedValue=$item->DataItem['category'];
+ }
+ }
+
+ public function saveInput($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $index=0;
+ $products=$this->Products;
+ $data=array();
+ foreach($this->Repeater->Items as $item)
+ {
+ $item=array(
+ 'id'=>$products[$index]['id'],
+ 'name'=>$item->ProductName->Text,
+ 'category'=>$item->ProductCategory->SelectedItem->Text,
+ 'price'=>TPropertyValue::ensureFloat($item->ProductPrice->Text),
+ 'imported'=>$item->ProductImported->Checked,
+ );
+ $data[]=$item;
+ $index++;
+ }
+ $this->Repeater2->DataSource=$data;
+ $this->Repeater2->dataBind();
+ }
+ }
+
+ public function renderRepeater2 ($sender, $param)
+ {
+ $this->Repeater2->render($param->getNewWriter());
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.page
new file mode 100644
index 00000000..b4bb622c
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.page
@@ -0,0 +1,27 @@
+<com:TContent ID="body">
+
+<h1>TActiveRepeater Sample 4</h1>
+
+<p>Please enter the URL of your favorite websites in the following:</p>
+<com:TActiveRepeater ID="Repeater"
+ OnItemCreated="itemCreated"
+ ItemRenderer="TTextBox"
+ />
+
+<br/>
+
+<com:TActiveButton Text="Submit" OnClick="buttonClicked" OnCallback="redrawRepeater2"/>
+
+<br/><br/>
+
+<com:TActiveLabel id="lblResult" Text="You have entered the following URLs:"
+ Display="None" />
+<br/>
+
+<com:TActiveRepeater ID="Repeater2"
+ OnItemCreated="itemCreated"
+ ItemRenderer="THyperLink"
+ />
+
+
+<div class="last-modified">$Id: Sample4.page 1688 2007-02-09 22:48:31Z xue $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.php
new file mode 100644
index 00000000..0b42436e
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.php
@@ -0,0 +1,43 @@
+<?php
+
+Prado::using('System.Collections.TDummyDataSource');
+
+class Sample4 extends TPage
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ // use a dummy data source to create 3 repeater items
+ $this->Repeater->DataSource=new TDummyDataSource(3);
+ $this->Repeater->dataBind();
+ }
+ }
+
+ public function itemCreated($sender,$param)
+ {
+ // $param->Item refers to the newly created repeater item
+ $param->Item->Style="width:300px; margin:10px; margin-left:0px";
+ }
+
+ public function buttonClicked($sender,$param)
+ {
+ $links=array();
+ foreach($this->Repeater->Items as $textBox)
+ {
+ if($textBox->Text!=='')
+ $links[]=$textBox->Text;
+ }
+ $this->Repeater2->DataSource=$links;
+ $this->Repeater2->dataBind();
+ }
+
+ public function redrawRepeater2($sender,$param)
+ {
+ $this->lblResult->setDisplay(TDisplayStyle::Dynamic);
+ $this->Repeater2->render($param->NewWriter);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.page
new file mode 100644
index 00000000..ee9992d9
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.page
@@ -0,0 +1,18 @@
+<com:TContent ID="body">
+
+<h1>TActiveRepeater Sample 5</h1>
+
+<com:TActiveRepeater ID="Repeater"
+ ItemRenderer="Application.pages.ActiveControls.Samples.TActiveRepeater.RegionDisplay">
+
+<prop:HeaderTemplate>
+<table cellspacing="1" style="border:1px solid silver">
+</prop:HeaderTemplate>
+
+<prop:FooterTemplate>
+</table>
+</prop:FooterTemplate>
+
+</com:TActiveRepeater>
+
+<div class="last-modified">$Id: $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.php
new file mode 100644
index 00000000..60beb30e
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.php
@@ -0,0 +1,52 @@
+<?php
+
+class Sample5 extends TPage
+{
+ protected function getData()
+ {
+ return array(
+ array(
+ 'name'=>'North',
+ 'detail'=>array(
+ array('name'=>'John','age'=>30,'position'=>'Program Manager'),
+ array('name'=>'Edward','age'=>35,'position'=>'Developer'),
+ array('name'=>'Walter','age'=>28,'position'=>'Developer'),
+ ),
+ ),
+ array(
+ 'name'=>'West',
+ 'detail'=>array(
+ array('name'=>'Cary','age'=>31,'position'=>'Senior Manager'),
+ array('name'=>'Ted','age'=>25,'position'=>'Developer'),
+ array('name'=>'Kevin','age'=>28,'position'=>'Developer'),
+ ),
+ ),
+ array(
+ 'name'=>'East',
+ 'detail'=>array(
+ array('name'=>'Shawn','age'=>30,'position'=>'Sales Manager'),
+ array('name'=>'Larry','age'=>28,'position'=>'Document Writer'),
+ ),
+ ),
+ array(
+ 'name'=>'South',
+ 'detail'=>array(
+ array('name'=>'King','age'=>30,'position'=>'Program Manager'),
+ array('name'=>'Carter','age'=>22,'position'=>'Developer'),
+ ),
+ ),
+ );
+ }
+
+ public 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/framework/Web/UI/ActiveControls/TActiveDataGrid.php b/framework/Web/UI/ActiveControls/TActiveDataGrid.php
new file mode 100644
index 00000000..8fefe646
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TActiveDataGrid.php
@@ -0,0 +1,630 @@
+<?php
+/**
+ * TActiveDataGrid class file
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @link http://www.landwehr-software.de/
+ * @copyright Copyright &copy; 2009 LANDWEHR Computer und Software GmbH
+ * @license http://www.pradosoft.com/license/
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Includes the following used classes
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
+Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
+Prado::using('System.Web.UI.ActiveControls.TActiveImageButton');
+Prado::using('System.Web.UI.ActiveControls.TActiveButton');
+Prado::using('System.Web.UI.ActiveControls.TActiveImage');
+Prado::using('System.Web.UI.ActiveControls.TActiveCheckBox');
+Prado::using('System.Web.UI.WebControls.TDataGrid');
+Prado::using('System.Web.UI.WebControls.TBoundColumn');
+Prado::using('System.Web.UI.WebControls.TEditCommandColumn');
+Prado::using('System.Web.UI.WebControls.TButtonColumn');
+Prado::using('System.Web.UI.WebControls.THyperLinkColumn');
+Prado::using('System.Web.UI.WebControls.TCheckBoxColumn');
+
+/**
+ * TActiveDataGrid class
+ *
+ * TActiveDataGrid represents a data bound and updatable grid control which is the
+ * active counterpart to the original {@link TDataGrid} control.
+ *
+ * This component can be used in the same way as the regular datagrid, the only
+ * difference is that the active datagrid uses callbacks instead of postbacks
+ * for interaction.
+ *
+ * There are also active datagrid columns to work with the TActiveDataGrid, which are
+ * - {@link TActiveBoundColumn}, the active counterpart to {@link TBoundColumn}.
+ * - {@link TActiveEditCommandColumn}, the active counterpart to {@link TEditCommandColumn}.
+ * - {@link TActiveButtonColumn}, the active counterpart to {@link TButtonColumn}.
+ *
+ * Please refer to the original documentation of the regular counterparts for usage.
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @package System.Web.UI.ActiveControls
+ * @since 3.2
+ */
+class TActiveDataGrid extends TDataGrid implements IActiveControl, ISurroundable {
+/**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter.
+ */
+ public function __construct() {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveControl standard active control options.
+ */
+ public function getActiveControl() {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * Sets the data source object associated with the datagrid control.
+ * In addition, the render method of all connected pagers is called so they
+ * get updated when the data source is changed. Also the datagrid registers
+ * itself for rendering in order to get it's content replaced on client side.
+ * @param Traversable|array|string data source object
+ */
+ public function setDataSource($value) {
+ parent::setDataSource($value);
+ if($this->getActiveControl()->canUpdateClientSide()) {
+ $this->renderPager();
+ $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter());
+ }
+ }
+
+ /**
+ * Returns the id of the surrounding container (span).
+ * @return string container id
+ */
+ public function getSurroundingTagId() {
+ return $this->ClientID.'_Container';
+ }
+
+ /**
+ * Creates a pager button.
+ * Depending on the button type, a TActiveLinkButton or a TActiveButton may be created.
+ * If it is enabled (clickable), its command name and parameter will also be set.
+ * It overrides the datagrid's original method to create active controls instead, thus
+ * the pager will do callbacks instead of the regular postbacks.
+ * @param string button type, either LinkButton or PushButton
+ * @param boolean whether the button should be enabled
+ * @param string caption of the button
+ * @param string CommandName corresponding to the OnCommand event of the button
+ * @param string CommandParameter corresponding to the OnCommand event of the button
+ * @return mixed the button instance
+ */
+ protected function createPagerButton($buttonType,$enabled,$text,$commandName,$commandParameter) {
+ if($buttonType===TDataGridPagerButtonType::LinkButton) {
+ if($enabled)
+ $button=new TActiveLinkButton;
+ else {
+ $button=new TLabel;
+ $button->setText($text);
+ return $button;
+ }
+ }
+ else {
+ $button=new TActiveButton;
+ if(!$enabled)
+ $button->setEnabled(false);
+ }
+ $button->setText($text);
+ $button->setCommandName($commandName);
+ $button->setCommandParameter($commandParameter);
+ $button->setCausesValidation(false);
+ return $button;
+ }
+
+ /**
+ * Renders the datagrid.
+ * If the datagrid did not pass the prerender phase yet, it will register itself for rendering later.
+ * Else it will call the {@link renderDataGrid()} method which will do the rendering of the datagrid.
+ * @param THtmlWriter writer for the rendering purpose
+ */
+ public function render($writer) {
+ if($this->getHasPreRendered()) {
+ $this->renderDataGrid($writer);
+ if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(),$writer);
+ }
+ else {
+ $this->getPage()->getAdapter()->registerControlToRender($this,$writer);
+ }
+ }
+
+ /**
+ * Loops through all {@link TActivePager} on the page and registers the ones which are set to paginate
+ * the datagrid for rendering. This is to ensure that the connected pagers are also rendered if the
+ * data source changed.
+ */
+ private function renderPager() {
+ $pager=$this->getPage()->findControlsByType('TActivePager', false);
+ foreach($pager as $item) {
+ if($item->ControlToPaginate==$this->ID) {
+ $writer=$this->getResponse()->createHtmlWriter();
+ $this->getPage()->getAdapter()->registerControlToRender($item,$writer);
+ }
+ }
+ }
+
+ /**
+ * Renders the datagrid by writing a span tag with the container id obtained from {@link getSurroundingTagId()}
+ * which will be called by the replacement method of the client script to update it's content.
+ * @param THtmlWriter writer for the rendering purpose
+ */
+ private function renderDataGrid($writer) {
+ $writer->write('<span id="'.$this->getSurroundingTagId().'">');
+ parent::render($writer);
+ $writer->write('</span>');
+ }
+}
+
+
+/**
+ * TActiveBoundColumn class
+ *
+ * TActiveBoundColumn represents a column that is bound to a field in a data source.
+ * The cells in the column will be displayed using the data indexed by
+ * {@link setDataField DataField}. You can customize the display by
+ * setting {@link setDataFormatString DataFormatString}.
+ *
+ * This is the active counterpart to the {@link TBoundColumn} control. For that purpose,
+ * if sorting is allowed, the header links/buttons are replaced by active controls.
+ *
+ * Please refer to the original documentation of the {@link TBoundColumn} for usage.
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @package LANDWEHR.ActiveControls
+ * @since 3.1.4
+ */
+class TActiveBoundColumn extends TBoundColumn {
+ protected function initializeHeaderCell($cell,$columnIndex) {
+ $text=$this->getHeaderText();
+
+ if(($classPath=$this->getHeaderRenderer())!=='') {
+ $control=Prado::createComponent($classPath);
+ if($control instanceof IDataRenderer) {
+ if($control instanceof IItemDataRenderer) {
+ $item=$cell->getParent();
+ $control->setItemIndex($item->getItemIndex());
+ $control->setItemType($item->getItemType());
+ }
+ $control->setData($text);
+ }
+ $cell->getControls()->add($control);
+ }
+ else if($this->getAllowSorting()) {
+ $sortExpression=$this->getSortExpression();
+ if(($url=$this->getHeaderImageUrl())!=='') {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton');
+ $button->setImageUrl($url);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ if($text!=='') {
+ $button->setAlternateText($text);
+ $button->setToolTip($text);
+ }
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else if($text!=='') {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton');
+ $button->setText($text);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else
+ $cell->setText('&nbsp;');
+ }
+ else {
+ if(($url=$this->getHeaderImageUrl())!=='') {
+ $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage');
+ $image->setImageUrl($url);
+ if($text!=='') {
+ $image->setAlternateText($text);
+ $image->setToolTip($text);
+ }
+ $cell->getControls()->add($image);
+ }
+ else if($text!=='')
+ $cell->setText($text);
+ else
+ $cell->setText('&nbsp;');
+ }
+ }
+}
+
+
+/**
+ * TActiveEditCommandColumn class
+ *
+ * TActiveEditCommandColumn contains the Edit command buttons for editing data items in each row.
+ *
+ * TActiveEditCommandColumn will create an edit button if a cell is not in edit mode.
+ * Otherwise an update button and a cancel button will be created within the cell.
+ * The button captions are specified using {@link setEditText EditText},
+ * {@link setUpdateText UpdateText}, and {@link setCancelText CancelText}.
+ *
+ * This is the active counterpart to the {@link TEditCommandColumn} control. The buttons for
+ * interaction are replaced by active buttons.
+ *
+ * Please refer to the original documentation of the {@link TEditCommandColumn} for usage.
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @package LANDWEHR.ActiveControls
+ * @since 3.1.4
+ */
+class TActiveEditCommandColumn extends TEditCommandColumn {
+ protected function createButton($commandName,$text,$causesValidation,$validationGroup) {
+ if($this->getButtonType()===TButtonColumnType::LinkButton)
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton');
+ else if($this->getButtonType()===TButtonColumnType::PushButton)
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveButton');
+ else // image buttons
+ {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton');
+ $button->setToolTip($text);
+ if(strcasecmp($commandName,'Update')===0)
+ $url=$this->getUpdateImageUrl();
+ else if(strcasecmp($commandName,'Cancel')===0)
+ $url=$this->getCancelImageUrl();
+ else
+ $url=$this->getEditImageUrl();
+ $button->setImageUrl($url);
+ }
+ $button->setText($text);
+ $button->setCommandName($commandName);
+ $button->setCausesValidation($causesValidation);
+ $button->setValidationGroup($validationGroup);
+ return $button;
+ }
+}
+
+
+/**
+ * TActiveButtonColumn class
+ *
+ * TActiveButtonColumn contains a user-defined command button, such as Add or Remove,
+ * that corresponds with each row in the column.
+ *
+ * This is the active counterpart to the {@link TButtonColumn} control where the
+ * button is replaced by the appropriate active button control.
+ *
+ * Please refer to the original documentation of the {@link TButtonColumn} for usage.
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @package LANDWEHR.ActiveControls
+ * @since 3.1.4
+ */
+class TActiveButtonColumn extends TButtonColumn {
+ public function initializeCell($cell,$columnIndex,$itemType) {
+ if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem) {
+ $buttonType=$this->getButtonType();
+ if($buttonType===TButtonColumnType::LinkButton)
+ $button=new TActiveLinkButton;
+ else if($buttonType===TButtonColumnType::PushButton)
+ $button=new TActiveButton;
+ else // image button
+ {
+ $button=new TActiveImageButton;
+ $button->setImageUrl($this->getImageUrl());
+ $button->setToolTip($this->getText());
+ }
+ $button->setText($this->getText());
+ $button->setCommandName($this->getCommandName());
+ $button->setCausesValidation($this->getCausesValidation());
+ $button->setValidationGroup($this->getValidationGroup());
+ if($this->getDataTextField()!=='' || ($buttonType===TButtonColumnType::ImageButton && $this->getDataImageUrlField()!==''))
+ $button->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
+ $cell->getControls()->add($button);
+ $cell->registerObject('Button',$button);
+ }
+ else
+ parent::initializeCell($cell,$columnIndex,$itemType);
+ }
+}
+
+
+/**
+ * TActiveTemplateColumn class
+ *
+ * TActiveTemplateColumn customizes the layout of controls in the column with templates.
+ * In particular, you can specify {@link setItemTemplate ItemTemplate},
+ * {@link setEditItemTemplate EditItemTemplate}, {@link setHeaderTemplate HeaderTemplate}
+ * and {@link setFooterTemplate FooterTemplate} to customize specific
+ * type of cells in the column.
+ *
+ * This is the active counterpart to the {@link TTemplateColumn} control. For that purpose,
+ * if sorting is allowed, the header links/buttons are replaced by active controls.
+ *
+ * Please refer to the original documentation of the {@link TTemplateColumn} for usage.
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @package LANDWEHR.ActiveControls
+ * @since 3.1.4
+ */
+class TActiveTemplateColumn extends TTemplateColumn {
+ protected function initializeHeaderCell($cell,$columnIndex) {
+ $text=$this->getHeaderText();
+
+ if(($classPath=$this->getHeaderRenderer())!=='') {
+ $control=Prado::createComponent($classPath);
+ if($control instanceof IDataRenderer) {
+ if($control instanceof IItemDataRenderer) {
+ $item=$cell->getParent();
+ $control->setItemIndex($item->getItemIndex());
+ $control->setItemType($item->getItemType());
+ }
+ $control->setData($text);
+ }
+ $cell->getControls()->add($control);
+ }
+ else if($this->getAllowSorting()) {
+ $sortExpression=$this->getSortExpression();
+ if(($url=$this->getHeaderImageUrl())!=='') {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton');
+ $button->setImageUrl($url);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ if($text!=='')
+ $button->setAlternateText($text);
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else if($text!=='') {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton');
+ $button->setText($text);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else
+ $cell->setText('&nbsp;');
+ }
+ else {
+ if(($url=$this->getHeaderImageUrl())!=='') {
+ $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage');
+ $image->setImageUrl($url);
+ if($text!=='')
+ $image->setAlternateText($text);
+ $cell->getControls()->add($image);
+ }
+ else if($text!=='')
+ $cell->setText($text);
+ else
+ $cell->setText('&nbsp;');
+ }
+ }
+}
+
+class TActiveHyperLinkColumn extends THyperLinkColumn
+{
+
+ protected function initializeHeaderCell($cell,$columnIndex)
+ {
+ $text=$this->getHeaderText();
+
+ if(($classPath=$this->getHeaderRenderer())!=='')
+ {
+ $control=Prado::createComponent($classPath);
+ if($control instanceof IDataRenderer)
+ {
+ if($control instanceof IItemDataRenderer)
+ {
+ $item=$cell->getParent();
+ $control->setItemIndex($item->getItemIndex());
+ $control->setItemType($item->getItemType());
+ }
+ $control->setData($text);
+ }
+ $cell->getControls()->add($control);
+ }
+ else if($this->getAllowSorting())
+ {
+ $sortExpression=$this->getSortExpression();
+ if(($url=$this->getHeaderImageUrl())!=='')
+ {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton');
+ $button->setImageUrl($url);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ if($text!=='')
+ $button->setAlternateText($text);
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else if($text!=='')
+ {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton');
+ $button->setText($text);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else
+ $cell->setText('&nbsp;');
+ }
+ else
+ {
+ if(($url=$this->getHeaderImageUrl())!=='')
+ {
+ $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage');
+ $image->setImageUrl($url);
+ if($text!=='')
+ $image->setAlternateText($text);
+ $cell->getControls()->add($image);
+ }
+ else if($text!=='')
+ $cell->setText($text);
+ else
+ $cell->setText('&nbsp;');
+ }
+ }
+}
+
+class TActiveCheckBoxColumn extends TCheckBoxColumn
+{
+ /**
+ * Initializes the specified cell to its initial values.
+ * This method overrides the parent implementation.
+ * It creates a checkbox inside the cell.
+ * If the column is read-only or if the item is not in edit mode,
+ * the checkbox will be set disabled.
+ * @param TTableCell the cell to be initialized.
+ * @param integer the index to the Columns property that the cell resides in.
+ * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
+ */
+ public function initializeCell($cell,$columnIndex,$itemType)
+ {
+ if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem)
+ {
+ $checkBox=new TActiveCheckBox;
+ if($this->getReadOnly() || $itemType!==TListItemType::EditItem)
+ $checkBox->setEnabled(false);
+ $cell->setHorizontalAlign('Center');
+ $cell->getControls()->add($checkBox);
+ $cell->registerObject('CheckBox',$checkBox);
+ if($this->getDataField()!=='')
+ $checkBox->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
+ }
+ else
+ parent::initializeCell($cell,$columnIndex,$itemType);
+ }
+
+ protected function initializeHeaderCell($cell,$columnIndex)
+ {
+ $text=$this->getHeaderText();
+
+ if(($classPath=$this->getHeaderRenderer())!=='')
+ {
+ $control=Prado::createComponent($classPath);
+ if($control instanceof IDataRenderer)
+ {
+ if($control instanceof IItemDataRenderer)
+ {
+ $item=$cell->getParent();
+ $control->setItemIndex($item->getItemIndex());
+ $control->setItemType($item->getItemType());
+ }
+ $control->setData($text);
+ }
+ $cell->getControls()->add($control);
+ }
+ else if($this->getAllowSorting())
+ {
+ $sortExpression=$this->getSortExpression();
+ if(($url=$this->getHeaderImageUrl())!=='')
+ {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton');
+ $button->setImageUrl($url);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ if($text!=='')
+ $button->setAlternateText($text);
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else if($text!=='')
+ {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton');
+ $button->setText($text);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else
+ $cell->setText('&nbsp;');
+ }
+ else
+ {
+ if(($url=$this->getHeaderImageUrl())!=='')
+ {
+ $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage');
+ $image->setImageUrl($url);
+ if($text!=='')
+ $image->setAlternateText($text);
+ $cell->getControls()->add($image);
+ }
+ else if($text!=='')
+ $cell->setText($text);
+ else
+ $cell->setText('&nbsp;');
+ }
+ }
+}
+
+class TActiveDropDownListColumn extends TDropDownListColumn
+{
+ protected function initializeHeaderCell($cell,$columnIndex)
+ {
+ $text=$this->getHeaderText();
+
+ if(($classPath=$this->getHeaderRenderer())!=='')
+ {
+ $control=Prado::createComponent($classPath);
+ if($control instanceof IDataRenderer)
+ {
+ if($control instanceof IItemDataRenderer)
+ {
+ $item=$cell->getParent();
+ $control->setItemIndex($item->getItemIndex());
+ $control->setItemType($item->getItemType());
+ }
+ $control->setData($text);
+ }
+ $cell->getControls()->add($control);
+ }
+ else if($this->getAllowSorting())
+ {
+ $sortExpression=$this->getSortExpression();
+ if(($url=$this->getHeaderImageUrl())!=='')
+ {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton');
+ $button->setImageUrl($url);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ if($text!=='')
+ $button->setAlternateText($text);
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else if($text!=='')
+ {
+ $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton');
+ $button->setText($text);
+ $button->setCommandName(TDataGrid::CMD_SORT);
+ $button->setCommandParameter($sortExpression);
+ $button->setCausesValidation(false);
+ $cell->getControls()->add($button);
+ }
+ else
+ $cell->setText('&nbsp;');
+ }
+ else
+ {
+ if(($url=$this->getHeaderImageUrl())!=='')
+ {
+ $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage');
+ $image->setImageUrl($url);
+ if($text!=='')
+ $image->setAlternateText($text);
+ $cell->getControls()->add($image);
+ }
+ else if($text!=='')
+ $cell->setText($text);
+ else
+ $cell->setText('&nbsp;');
+ }
+ }
+
+} \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveRepeater.php b/framework/Web/UI/ActiveControls/TActiveRepeater.php
new file mode 100644
index 00000000..941b6322
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TActiveRepeater.php
@@ -0,0 +1,105 @@
+<?php
+
+/**
+ * TActiveRepeater class
+ *
+ * TActiveRepeater represents a data bound and updatable grid control which is the
+ * active counterpart to the original {@link TRepeater} control.
+ *
+ * This component can be used in the same way as the regular datagrid, the only
+ * difference is that the active repeater uses callbacks instead of postbacks
+ * for interaction.
+ *
+ * Please refer to the original documentation of the regular counterparts for usage.
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @package System.Web.UI.ActiveControls
+ * @since 3.2
+ */
+class TActiveRepeater extends TRepeater implements IActiveControl, ISurroundable {
+
+/**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter.
+ */
+ public function __construct() {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveControl standard active control options.
+ */
+ public function getActiveControl() {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * Sets the data source object associated with the repeater control.
+ * In addition, the render method of all connected pagers is called so they
+ * get updated when the data source is changed. Also the repeater registers
+ * itself for rendering in order to get it's content replaced on client side.
+ * @param Traversable|array|string data source object
+ */
+ public function setDataSource($value) {
+ parent::setDataSource($value);
+ if($this->getActiveControl()->canUpdateClientSide()) {
+ $this->renderPager();
+ $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter());
+ }
+ }
+
+ /**
+ * Returns the id of the surrounding container (span).
+ * @return string container id
+ */
+ public function getSurroundingTagID() {
+ return $this->ClientID.'_Container';
+ }
+
+ /**
+ * Renders the repeater.
+ * If the repeater did not pass the prerender phase yet, it will register itself for rendering later.
+ * Else it will call the {@link renderRepeater()} method which will do the rendering of the repeater.
+ * @param THtmlWriter writer for the rendering purpose
+ */
+ public function render($writer) {
+ if($this->getHasPreRendered()) {
+ $this->renderRepeater($writer);
+ if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(),$writer);
+ }
+ else {
+ $this->getPage()->getAdapter()->registerControlToRender($this,$writer);
+ }
+ }
+
+ /**
+ * Loops through all {@link TActivePager} on the page and registers the ones which are set to paginate
+ * the repeater for rendering. This is to ensure that the connected pagers are also rendered if the
+ * data source changed.
+ */
+ private function renderPager() {
+ $pager=$this->getPage()->findControlsByType('TActivePager', false);
+ foreach($pager as $item) {
+ if($item->ControlToPaginate==$this->ID) {
+ $writer=$this->getResponse()->createHtmlWriter();
+ $this->getPage()->getAdapter()->registerControlToRender($item,$writer);
+ }
+ }
+ }
+
+ /**
+ * Renders the repeater by writing a span tag with the container id obtained from {@link getSurroundingTagID()}
+ * which will be called by the replacement method of the client script to update it's content.
+ * @param THtmlWriter writer for the rendering purpose
+ */
+ private function renderRepeater($writer) {
+ $writer->addAttribute('id',$this->getSurroundingTagID());
+ $writer->renderBeginTag('span');
+ parent::render($writer);
+ $writer->renderEndTag();
+ }
+
+}
+
+?> \ No newline at end of file