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/Sample3.php | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php (limited to 'demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php') 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