blob: e928632dbe80721894097130f191544374c8ea5e (
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
|
<?php
Prado::using('System.Web.UI.ActiveControls.*');
class Ticket384 extends TPage
{
public function initRecursive($namingContainer=null)
{
parent::initRecursive($namingContainer);
$this->AutoCompleteRepeater->setDataSource(array(1, 2));
$this->AutoCompleteRepeater->dataBind();
}
public function submitCallback($sender, $param)
{
$this->AutoCompleteRepeater->setDataSource(array(1,2,3,4));
$this->AutoCompleteRepeater->dataBind();
$this->AutoCompletePanel->render($this->getResponse()->createHtmlWriter());
}
public function suggestCountries($sender, $param)
{
$sender->setDataSource($this->matchCountries($param->getCallbackParameter()));
$sender->dataBind();
}
protected function matchCountries($token)
{
$info = Prado::createComponent('System.I18N.core.CultureInfo', 'en');
$list = array();
$count = 0;
$token = strtolower($token);
foreach($info->getCountries() as $country)
{
if(strpos(strtolower($country), $token) === 0)
{
$list[] = $country;
$count++;
if($count > 10) break;
}
}
return $list;
}
}
?>
|