sergiodlopes / jquery-flexdatalist

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

Set multiple values to edit dataset if URL is used #240

Open seven21 opened 2 years ago

seven21 commented 2 years ago

Hello, i am using the flexdatalist with the URL to load my data. Now if I want to edit a dataset I have to load the existing values to the multiple flexdatalist to show previous selected values. I use the data-value-property and data-visible-properties. So I have to set the value and the visible value. Using the "add" method seems to allow only selecting from an existing datalist. As I load the datalist always only by enetering at least 4 characters no datalist is available. Was wondering if I can initialize with "data" option and set the previous data that they can be selected with "add" method. But there is no description how the to format or if it is possible

Using: <input type="text" name="invoices" id="inputInvoice" placeholder="" class="flexdatalist form-control" data-url='{{ route('invoice.json') }}' data-search-in="invoice_id" data-visible-properties='["invoice_id"]' data-selection-required="true" data-value-property="id" data-min-length="4" multiple="multiple">

Try to add old values something like: $('#inputInvoice').flexdatalist( {data: [ {id : 21, invoice_id : "22842"} ]}); $('#inputInvoice').flexdatalist('add', 21)

sankhax commented 2 years ago

did you mean user can add some value if its not in database and store that to database? you can try this : $('#inputInvoice').flexdatalist( {noResultsText: '<button> Trigger Some Button </button>'});

if your mean user can add some value in multiple dataset just use comma or your valuesSeparator to add value

if your mean user can add some value that used before, you can try this: $('#inputInvoice').flexdatalist( {allowDuplicateValues: true} );