How can I do an autocomplete with two column search of the database?
I have already looked at several examples, and I have seen one that uses a grid genre, it is something like $("#seletor").combogrid(...)
.
I already managed to implement my autocomplete but only do the search by name of the article and I liked that I also did the search for id.
HTML
<input class="codigo autoC" type="text" placeholder="Nome ou Código do Artigo">
JQUERY
//Pedido ajax que retorna a lista dos artigos
myJSRoutes.controllers.c_base.c_artigos.ArtigoController.getAllArtigos().ajax({
success: function (data) {
if (data.length > 0) {
$.each(data, function (key, value) {
artigos.push(value.nome);
});
}
}
})
//AUTOCOMPLETE
$(document).on('click', '.autoC', function () {
$(".autoC").autocomplete({
source: artigos,
//REMOVE UM SPAN ADICIONADO AUTOMATICAMENTE AO GERAR O AUTOCOMPLETE
create: function (e) {
$(this).prev('.ui-helper-hidden-accessible').remove();
}
});
})
Any suggestions on how to search for id and name?