sergiodlopes / jquery-flexdatalist

Flexible input autocomplete/datalist plugin for jQuery
http://projects.sergiodinislopes.pt/flexdatalist/
MIT License
364 stars 84 forks source link

Unable to pre-select values for jquery Flexdatalist #222

Open hasanmk52 opened 4 years ago

hasanmk52 commented 4 years ago

$("input.flexdatalist").flexdatalist({ searchIn: 'name', cache: false, minLength: 0, url: ajaxGetCountries, requestType: "POST", resultsProperty: 'countries', multiple: true, visisbleProperties: ["name"], valueProperty: 'id', textProperty: '{name}' });

On focus of the input I am able to select multiple values by getting the json response from my Spring Boot controller but I am unable to pre-populate a certain number of values when the page is loaded on this field. The documentation gives an example but that is if the data is from a .json file but this is not the case here.

Can you please help resolve this issue? Also posted the same question on stackoverflow: https://stackoverflow.com/questions/62690539/unable-to-pre-select-values-for-jquery-flexdatalist

lerg96 commented 4 years ago

If the id on your json is a integer you have to use a string, because flexdatalist compares a string (from the input) and a integer (from the json)

jesuslotus commented 4 years ago

He logrado hacer andar la preseleccion de valores desde solicitudes remotas modificando la linea 568, pasando de === a ==. Captura de pantalla de 2020-10-14 12-08-07. Ojala le sea de ayuda a alguien.