summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDropDownList/Home.php
blob: b63bbd42e86046d6074ca35e5b3eaef8f5993948 (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
<?php

class Home extends TPage
{
	public function onLoad($param)
	{
		parent::onLoad($param);
		if(!$this->IsPostBack && !$this->IsCallback)
		{
			$this->resetClicked(null,null);
		}
	}

	protected function collectSelectionResult($input,$output)
	{
		$indices=$input->SelectedIndices;
		$result='';
		foreach($indices as $index)
		{
			$item=$input->Items[$index];
			$result.="(Index: $index, Value: $item->Value, Text: $item->Text)";
		}
		if($result==='')
			$output->Text='Your selection is empty.';
		else
			$output->Text='Your selection is: '.$result;
	}

	public function selectionChanged($sender,$param)
	{
		$this->collectSelectionResult($sender,$this->SelectionResult);
	}

	public function buttonClicked($sender, $param)
	{
		$data=array();
		for($i = 0; $i <= $this->ddl1->Items->Count; $i++)
			$data[$i]="Item number #".$i;
		$this->ddl1->DataSource=$data;
		$this->ddl1->dataBind();
		$this->label1->Text="Total ".count($data)." items";
	}

	public function resetClicked($sender, $param)
	{
		$data=array('item 1','item 2','item 3','item 4');
		$this->ddl2->DataSource=$data;
		$this->ddl2->dataBind();
		$this->label2->Text="DropDownList has been reset";
	}

	public function clearClicked($sender, $param)
	{
		$this->ddl2->DataSource=array();
		$this->ddl2->dataBind();
		$this->label2->Text="DropDownList cleared";
	}
}