summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php
blob: 59d01f571201a34a6079eb707b64314497fe5965 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?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];
	}

	protected 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();
		}
	}
}

?>