diff options
Diffstat (limited to 'demos/quickstart/protected/pages/Controls/Samples/TRepeater')
6 files changed, 310 insertions, 310 deletions
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php index 40d1841e..4f7ab6c2 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/RegionDisplay.php @@ -1,28 +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++;
- }
-}
-
+<?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/Sample1.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php index 905a3b8d..c3cff79b 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample1.php @@ -1,41 +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();
- }
- }
-}
-
+<?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/Controls/Samples/TRepeater/Sample2.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php index e84580a2..803201e9 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php @@ -1,79 +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++;
- }
- }
-}
-
+<?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/Controls/Samples/TRepeater/Sample3.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php index d4f4c8e9..dbaf598f 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample3.php @@ -1,79 +1,79 @@ -<?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->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();
- }
- }
-}
-
+<?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->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 diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php index aabab157..fb0e4922 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample4.php @@ -1,37 +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();
- }
-}
-
+<?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.php b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.php index 60beb30e..de6e5bd9 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample5.php @@ -1,52 +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();
- }
- }
-}
-
+<?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 |