[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 3 class Sample3 extends TPage 4 { 5 protected function getProducts() 6 { 7 return array( 8 array('id'=>'ITN001','name'=>'Motherboard','category'=>'CAT004','price'=>100.00,'imported'=>true), 9 array('id'=>'ITN002','name'=>'CPU','category'=>'CAT004','price'=>150.00,'imported'=>true), 10 array('id'=>'ITN003','name'=>'Harddrive','category'=>'CAT003','price'=>80.00,'imported'=>true), 11 array('id'=>'ITN006','name'=>'Keyboard','category'=>'CAT002','price'=>20.00,'imported'=>false), 12 array('id'=>'ITN008','name'=>'CDRW drive','category'=>'CAT003','price'=>40.00,'imported'=>true), 13 array('id'=>'ITN009','name'=>'Cooling fan','category'=>'CAT001','price'=>10.00,'imported'=>false), 14 array('id'=>'ITN012','name'=>'Floppy drive','category'=>'CAT003','price'=>12.00,'imported'=>false), 15 array('id'=>'ITN013','name'=>'CD drive','category'=>'CAT003','price'=>20.00,'imported'=>true), 16 array('id'=>'ITN014','name'=>'DVD drive','category'=>'CAT003','price'=>80.00,'imported'=>true), 17 array('id'=>'ITN015','name'=>'Mouse pad','category'=>'CAT001','price'=>5.00,'imported'=>false), 18 ); 19 } 20 21 protected function getCategories() 22 { 23 return array( 24 array('id'=>'CAT001','name'=>'Accessories'), 25 array('id'=>'CAT002','name'=>'Input Devices'), 26 array('id'=>'CAT003','name'=>'Drives'), 27 array('id'=>'CAT004','name'=>'Barebone'), 28 ); 29 } 30 31 public function onLoad($param) 32 { 33 parent::onLoad($param); 34 if(!$this->IsPostBack) 35 { 36 $this->Repeater->DataSource=$this->Products; 37 $this->Repeater->dataBind(); 38 } 39 } 40 41 public function repeaterDataBound($sender,$param) 42 { 43 $item=$param->Item; 44 if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem') 45 { 46 $item->ProductCategory->DataSource=$this->Categories; 47 $item->ProductCategory->DataTextField='name'; 48 $item->ProductCategory->DataValueField='id'; 49 $item->ProductCategory->dataBind(); 50 $item->ProductCategory->SelectedValue=$item->DataItem['category']; 51 } 52 } 53 54 public function saveInput($sender,$param) 55 { 56 if($this->IsValid) 57 { 58 $index=0; 59 $products=$this->Products; 60 $data=array(); 61 foreach($this->Repeater->Items as $item) 62 { 63 $item=array( 64 'id'=>$products[$index]['id'], 65 'name'=>$item->ProductName->Text, 66 'category'=>$item->ProductCategory->SelectedItem->Text, 67 'price'=>TPropertyValue::ensureFloat($item->ProductPrice->Text), 68 'imported'=>$item->ProductImported->Checked, 69 ); 70 $data[]=$item; 71 $index++; 72 } 73 $this->Repeater2->DataSource=$data; 74 $this->Repeater2->dataBind(); 75 } 76 } 77 } 78 79 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |