summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Controls/Samples/TRepeater/Sample2.php
blob: 96096a8aac5d7253f2b5c094e6adda3ee1699198 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?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++;
	}
}

?>