Remplir un kendoDropDownList avec appel Ajax
Salutation à tous!!!
Voila je travail en ce moment avec l'API de KendoUI. Et la j'expérimente l'utilisation d'un kendoDropDownList (une liste déroulante avec une recherche avec autocompletion lien ici: http://demos.telerik.com/kendo-ui/dr...erverfiltering). Du coup j'essaie charger cette liste avec une action d'un de mes controller sur Symfony. Pour cela kendoUI utilise des datasource et j'essaie de faire un appel ajax dessus pour récupérer mes données. Mais Pour l'instant rien ne fonction et je trouve rien sur internet sur charger ce kendoDropDownList en utilisant du php.
voici le javascript:
Code:
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
| $("#recherche_pef").kendoDropDownList({
filter: "startswith",
dataTextField: "NomPEF",//valeur à rechercher
dataValueField: "IDPEF",//valeur retounrné après recherche (genre id pour traitement)
placeholder: "Rechercher un PEF/DP...",
dataSource: {
//type: "odata",
serverFiltering: true,
transport: {
/*read: {
//url: "EventsSaisieDepart/RecherchePEF",
url: "RecherchePEF",
dataType: "json"
}*/
read: function(options) {
$.ajax({
type: "GET",
url: "EventsSaisieDepart/RecherchePEF",
// contentType: "application/json; charset=utf-8",
dataType: 'json',
//data: JSON.stringify({key: "value"}),
success: function(data) {
options.success(data);
}
});
}
}
}
}); |
L'action de mon controller symfony:
Code:
1 2 3 4 5 6 7 8 9 10 11
| public function RecherchePEFAction(){
$test = "coucou";
$test2 = $_GET['$inlinecount'];
$test3 = $_GET['filter'];
//$tab = array();
$tab = array("IDPEF"=>"1", "NomPEF" => "gare du nord");
//$tab = array("IDPEF"=>"2", "NomPEF" => "gare du sud");
//$tab = array("IDPEF"=>"3", "NomPEF" => "gare de l'est");
return json_encode($tab);
//var_dump($tab);
} |
Voila quelqu'un aurait-il une solution ou s'y connaitrait en kendoUI ?? Car la je bloque complètement... Merci d'avance!!!