summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/ActiveControls/Samples/TAutoComplete/Home.php
blob: a3b9529b479e4ebebaf84953f380589403de7d12 (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
<?php
// $Id: Home.php 3189 2012-07-12 12:16:21Z ctrlaltca $
class Home extends TPage
{
    public function suggestNames($sender,$param) {
        // Get the token
        $token=$param->getToken();
        // Sender is the Suggestions repeater
        $sender->DataSource=$this->getDummyData($token);
        $sender->dataBind();
    }

    public function suggestionSelected1($sender,$param) {
        $id=$sender->Suggestions->DataKeys[ $param->selectedIndex ];
        $this->Selection1->Text='Selected ID: '.$id;
    }

    public function suggestionSelected2($sender,$param) {
        $id=$sender->Suggestions->DataKeys[ $param->selectedIndex ];
        $this->Selection2->Text='Selected ID: '.$id;
    }

    public function getDummyData($token) {
        // You would look for matches to the given token here
        return array(
            array('id'=>1, 'name'=>'John'),
            array('id'=>2, 'name'=>'Paul'),
            array('id'=>3, 'name'=>'George'),
            array('id'=>4, 'name'=>'Ringo')
        );
    }
}