0
Using Bootstrap-3-Typeahead plugin performing the search based on what the user type and displayed the information from another column of the database.
My server-side method performs the filter based on the services column and returns the name (colune name) of the establishments as a result and ta certinho, that is, when it is informed Website or Informatica the filter searches the test companies American and Microsoft and others I have as a test, but not list as selection option.
In this other post: Bootstrap-3-Typeahead does not list options Jorge showed me that it works in a simple way, but it does not meet my demand.
Follows my code:
$("#pesquisa").typeahead({
source: function (query) {
return $.get("/Estabelecimento/GetDados", { q: query });
},
minLength: 3
});
Html
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="input-group">
<input type="text" id="pesquisa" name="pesquisa" class="form-control typeahead" autocomplete="off" placeholder="Pesquisar" />
<div class="input-group-btn"><button class="btn btn-primary">Pesquisar</button></div>
</div>
</div>
</div>
</div>
Return of my $.get call when I search by site, it filters and brings the names below:
["Americanas", "Apple", "C & A", "Carrefour", "Microsfot", "Riachuelo", "Saraiva", "Sony"]
Ivan can indicate if I answered your question?
– Jorge Costa
No... it didn’t.. Look at the question that I say... Based on what the user type I should search in the service column, but the display should be the name of the establishments. Type. I have 2 establishments called, American and Microsoft and in each of them I have in the service column the word site, when searching by site, should appear the 2 establishments as suggestion. What does not occur.. the way posted I had already managed..
– Ivan Teles
I modified to meet what you are asking , can combine with the previous method but so have the exact answer to the request
– Jorge Costa
It still doesn’t meet my need. that’s how you did now when calling my method /Establishment/Getdata/? q=, as it does not pass anything as parameter already brings back all the record without running the filter that should occur on the server side.. I will adopt another plug.. such as jquery autocomplete.
– Ivan Teles