diff options
Diffstat (limited to 'demos/quickstart/protected/pages/JuiControls/Samples')
-rw-r--r-- | demos/quickstart/protected/pages/JuiControls/Samples/TJuiAutoComplete/Home.page | 45 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/JuiControls/Samples/TJuiAutoComplete/Home.php | 39 |
2 files changed, 84 insertions, 0 deletions
diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiAutoComplete/Home.page b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiAutoComplete/Home.page new file mode 100644 index 00000000..1338b651 --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiAutoComplete/Home.page @@ -0,0 +1,45 @@ +<com:TContent ID="body"> +<h1>TJuiAutoComplete Samples</h1> + + +<table class="sampletable"> + +<tr><td class="samplenote"> +Simple Autocompleter: +</td><td class="sampleaction"> +<com:TJuiAutoComplete + ID="AutoComplete" + OnSuggest="suggestNames" + OnSuggestionSelected="suggestionSelected1" + ResultPanel.CssClass="acomplete" + Suggestions.DataKeyField="id" > + + <prop:Suggestions.ItemTemplate> + <li><%# $this->Data['name'] %></li> + </prop:Suggestions.ItemTemplate> +</com:TJuiAutoComplete> +<com:TActiveLabel ID="Selection1" /> +</td></tr> + +<tr><td class="samplenote"> +Autocompleter with multiple selection: +</td><td class="sampleaction"> +<com:TJuiAutoComplete + ID="AutoComplete2" + OnSuggest="suggestNames" + OnSuggestionSelected="suggestionSelected2" + Separator="," + ResultPanel.CssClass="acomplete" + Suggestions.DataKeyField="id" > + + <prop:Suggestions.ItemTemplate> + <li><%# $this->Data['name'] %></li> + </prop:Suggestions.ItemTemplate> +</com:TJuiAutoComplete> +(Use ',' to separate the selected suggestions) +<com:TActiveLabel ID="Selection2" /> +</td></tr> + +</table> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiAutoComplete/Home.php b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiAutoComplete/Home.php new file mode 100644 index 00000000..c3fba3a9 --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiAutoComplete/Home.php @@ -0,0 +1,39 @@ +<?php + +class Home extends TPage +{ + public function suggestNames($sender,$param) { + // Get the token + $token=$param->getToken(); + // Sender is the Suggestions repeater + $sender->DataSource=$this->suggestionsForName($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 suggestionsForName($name) { + $allChoices = array( + array('id'=>1, 'name'=>'John'), + array('id'=>2, 'name'=>'Paul'), + array('id'=>3, 'name'=>'George'), + array('id'=>4, 'name'=>'Ringo') + ); + + if($name) { + return array_filter($allChoices, function ($el) use ($name) { + return stripos($el['name'], $name) !== false; + }); + } else + return $allChoices; + } + +}
\ No newline at end of file |