From 8c659a56ca8dccd8f3a427ad3121c2296c55e9ae Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 1 Feb 2006 02:05:08 +0000 Subject: Added a new repeater demo. --- .../pages/Controls/Samples/TRepeater/Sample1.page | 2 +- .../pages/Controls/Samples/TRepeater/Sample2.page | 10 ++- .../pages/Controls/Samples/TRepeater/Sample3.page | 92 ++++++++++++++++++++++ .../pages/Controls/Samples/TRepeater/Sample3.php | 79 +++++++++++++++++++ 4 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php (limited to 'demos/quickstart/protected') diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page index 8e469fde..1922ca2a 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.page @@ -2,7 +2,7 @@

TRepeater Sample 1

- + diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page index bb78c35a..b939c586 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.page @@ -3,11 +3,12 @@

TRepeater Sample 2

-
+
@@ -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. +

+ +
+ + + + + + + + + + + + + + + + +
NameCategoryPriceImported
+ Parent->DataItem['name']%> /> + + + + Parent->DataItem['price']%> /> + + Parent->DataItem['imported']%> /> + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDNameCategoryPriceImported
<%#$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