@@ -16,10 +17,13 @@
<%#$this->NamingContainer->DataItem %>
-
+
-
+
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page
new file mode 100644
index 00000000..115018ec
--- /dev/null
+++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page
@@ -0,0 +1,92 @@
+
+
+TRepeater Sample 3
+
+
+The following example allows users to modify the existing tabular data using a TRepeater. 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 save button, the input data is displayed in a table at the bottom of the page.
+
+
+
+
+ Name |
+ Category |
+ Price |
+ Imported |
+
+
+
+
+
+ Parent->DataItem['name']%> />
+ |
+
+
+ |
+
+ Parent->DataItem['price']%> />
+ |
+
+ Parent->DataItem['imported']%> />
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID |
+ Name |
+ Category |
+ Price |
+ Imported |
+
+
+
+
+
+<%#$this->Parent->DataItem['id']%> |
+<%#$this->Parent->DataItem['name']%> |
+<%#$this->Parent->DataItem['category']%> |
+<%#$this->Parent->DataItem['price']%> |
+<%#$this->Parent->DataItem['imported']?'Yes':'No'%> |
+
+
+
+
+
+Computer Parts Inventory |
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php
new file mode 100644
index 00000000..d4f4c8e9
--- /dev/null
+++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php
@@ -0,0 +1,79 @@
+'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->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();
+ }
+ }
+}
+
+?>
\ No newline at end of file
--
cgit v1.2.3
|