summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php
diff options
context:
space:
mode:
authorxue <>2006-01-26 05:29:54 +0000
committerxue <>2006-01-26 05:29:54 +0000
commit422eb693da395056f7aaba594be15bcc6b103bf2 (patch)
tree529684377c94b29d1f28cb8a90275262d26015bf /demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php
parent146cb7314bd0a9c05666605a2aa1fbff5c319447 (diff)
Added databinding and validation demos to TCheckBoxList and TRadioButtonList.
Diffstat (limited to 'demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php')
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php63
1 files changed, 55 insertions, 8 deletions
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php
index 47d9b23b..b45441f9 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php
+++ b/demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php
@@ -2,20 +2,67 @@
class Home extends TPage
{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $data=array('item 1','item 2','item 3','item 4');
+ $this->DBRadioButtonList1->DataSource=$data;
+ $this->DBRadioButtonList1->dataBind();
+
+ $data=array('key 1'=>'item 1','key 2'=>'item 2',
+ 'key 3'=>'item 3','key 4'=>'item 4');
+ $this->DBRadioButtonList2->DataSource=$data;
+ $this->DBRadioButtonList2->dataBind();
+
+ $data=array(
+ array('id'=>'001','name'=>'John','age'=>31),
+ array('id'=>'002','name'=>'Mary','age'=>30),
+ array('id'=>'003','name'=>'Cary','age'=>20));
+ $this->DBRadioButtonList3->DataSource=$data;
+ $this->DBRadioButtonList3->dataBind();
+ }
+ }
+
+ 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 buttonClicked($sender,$param)
{
- $index=$this->RadioButtonList->SelectedIndex;
- $value=$this->RadioButtonList->SelectedValue;
- $text=$this->RadioButtonList->SelectedItem->Text;
- $this->SelectionResult->Text="Your selection is (Index: $index, Value: $value, Text: $text).";
+ $this->collectSelectionResult($this->RadioButtonList,$this->SelectionResult);
}
public function selectionChanged($sender,$param)
{
- $index=$sender->SelectedIndex;
- $value=$sender->SelectedValue;
- $text=$sender->SelectedItem->Text;
- $this->SelectionResult2->Text="Your selection is (Index: $index, Value: $value, Text: $text).";
+ $this->collectSelectionResult($sender,$this->SelectionResult2);
+ }
+
+ public function DBRadioButtonList1Changed($sender,$param)
+ {
+ $this->collectSelectionResult($sender,$this->DBRadioButtonList1Result);
+ }
+
+ public function DBRadioButtonList2Changed($sender,$param)
+ {
+ $this->collectSelectionResult($sender,$this->DBRadioButtonList2Result);
+ }
+
+ public function DBRadioButtonList3Changed($sender,$param)
+ {
+ $this->collectSelectionResult($sender,$this->DBRadioButtonList3Result);
}
}