diff options
Diffstat (limited to 'demos/quickstart/protected/pages/Controls/Samples')
10 files changed, 222 insertions, 24 deletions
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php new file mode 100644 index 00000000..40d1841e --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/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/Controls/Samples/TRepeater/RegionDisplay.tpl b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.tpl new file mode 100644 index 00000000..0d0e46d3 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/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:TRepeater 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:TRepeater>
+
+</td>
+</tr>
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page index e3b3f6bd..e05d51bb 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page @@ -17,21 +17,21 @@ <prop:ItemTemplate>
<tr style="background-color:#BFCFFF">
-<td><%#$this->DataItem['id']%></td>
-<td><%#$this->DataItem['name']%></td>
-<td><%#$this->DataItem['quantity']%></td>
-<td><%#$this->DataItem['price']%></td>
-<td><%#$this->DataItem['imported']?'Yes':'No'%></td>
+<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->DataItem['id']%></td>
-<td><%#$this->DataItem['name']%></td>
-<td><%#$this->DataItem['quantity']%></td>
-<td><%#$this->DataItem['price']%></td>
-<td><%#$this->DataItem['imported']?'Yes':'No'%></td>
+<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>
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page index d1d75dc5..bd0e328a 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page @@ -14,7 +14,7 @@ <prop:ItemTemplate>
<tr>
<com:TTableCell ID="Cell">
- <%#$this->DataItem %>
+ <%#$this->Data %>
</com:TTableCell>
<td>
<com:TRepeater
@@ -29,13 +29,13 @@ <prop:ItemTemplate>
<com:TTableRow ID="Row">
<com:TTableCell Width="70px">
- <%#$this->DataItem['name'] %>
+ <%#$this->Data['name'] %>
</com:TTableCell>
<com:TTableCell Width="20">
- <%#$this->DataItem['age'] %>
+ <%#$this->Data['age'] %>
</com:TTableCell>
<com:TTableCell Width="150px">
- <%#$this->DataItem['position'] %>
+ <%#$this->Data['position'] %>
</com:TTableCell>
</com:TTableRow>
</prop:ItemTemplate>
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php index 96096a8a..e84580a2 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php @@ -60,8 +60,8 @@ class Sample2 extends TPage {
$item->Cell->BackColor=$itemIndex%2 ? "#6078BF" : "#809FFF";
$item->Cell->ForeColor='white';
+ $itemIndex++;
}
- $itemIndex++;
}
public function repeater2ItemCreated($sender,$param)
@@ -69,8 +69,10 @@ class Sample2 extends TPage static $itemIndex=0;
$item=$param->Item;
if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ {
$item->Row->BackColor=$itemIndex%2 ? "#BFCFFF" : "#E6ECFF";
- $itemIndex++;
+ $itemIndex++;
+ }
}
}
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page index c826420f..d90af751 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page @@ -19,7 +19,7 @@ The following example allows users to modify the existing tabular data using a < <td>
<com:TTextBox
ID="ProductName"
- Text=<%#$this->DataItem['name']%> />
+ Text=<%#$this->Data['name']%> />
</td>
<td>
<com:TDropDownList
@@ -29,12 +29,12 @@ The following example allows users to modify the existing tabular data using a < <com:TTextBox
ID="ProductPrice"
Columns="7"
- Text=<%#$this->DataItem['price']%> />
+ Text=<%#$this->Data['price']%> />
</td>
<td>
<com:TCheckBox
ID="ProductImported"
- Checked=<%#$this->DataItem['imported']%> />
+ Checked=<%#$this->Data['imported']%> />
<com:TRequiredFieldValidator
ControlToValidate="ProductName"
ErrorMessage="Product name cannot be empty."
@@ -70,11 +70,11 @@ The following example allows users to modify the existing tabular data using a < <prop:ItemTemplate>
<tr style="<%# 'background-color:' . ($this->ItemIndex%2 ? '#BFCFFF' : '#E6ECFF') %>">
-<td><%#$this->DataItem['id']%></td>
-<td><%#$this->DataItem['name']%></td>
-<td><%#$this->DataItem['category']%></td>
-<td><%#$this->DataItem['price']%></td>
-<td><%#$this->DataItem['imported']?'Yes':'No'%></td>
+<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>
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.page new file mode 100644 index 00000000..3a3c5ec1 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.page @@ -0,0 +1,27 @@ +<com:TContent ID="body">
+
+<h1>TRepeater Sample 4</h1>
+
+<p>Please enter the URL of your favorite websites in the following:</p>
+<com:TRepeater ID="Repeater"
+ OnItemCreated="itemCreated"
+ ItemRenderer="TTextBox"
+ />
+
+<br/>
+
+<com:TButton Text="Submit" OnClick="buttonClicked" />
+
+<br/><br/>
+
+<com:TLabel Text="You have entered the following URLs:"
+ Visible="<%= $this->IsPostBack %>" />
+<br/>
+
+<com:TRepeater ID="Repeater2"
+ OnItemCreated="itemCreated"
+ ItemRenderer="THyperLink"
+ />
+
+
+<div class="last-modified">$Id$</div></com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php new file mode 100644 index 00000000..aabab157 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php @@ -0,0 +1,37 @@ +<?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();
+ }
+}
+
+?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.page new file mode 100644 index 00000000..fa7254bd --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.page @@ -0,0 +1,18 @@ +<com:TContent ID="body">
+
+<h1>TRepeater Sample 5</h1>
+
+<com:TRepeater ID="Repeater"
+ ItemRenderer="Application.pages.Controls.Samples.TRepeater.RegionDisplay">
+
+<prop:HeaderTemplate>
+<table cellspacing="1" style="border:1px solid silver">
+</prop:HeaderTemplate>
+
+<prop:FooterTemplate>
+</table>
+</prop:FooterTemplate>
+
+</com:TRepeater>
+
+<div class="last-modified">$Id: $</div></com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.php new file mode 100644 index 00000000..60beb30e --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/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 |