Hello,
I want to implement select with the search but I am not able to do so and not even found any example of select with search on Vue demo.
// Select element
<!--begin::Select-->
<Field name="productId" data-control="select2" data-hide-search="true" data-placeholder="Select Product" class="form-select form-select-solid" as="select" v-model="apiData.productId" @change="setAdditionalOption(apiData.productId)">
<option value="">Select Product</option>
<option v-for="productDetail in product" :value="productDetail.product_id" :key="productDetail">
{{productDetail.product_name}}
</option>
</Field>
<div class="fv-plugins-message-container">
<div class="fv-help-block">
<ErrorMessage name="productId" />
</div>
</div>
<!--end::Select-->
@block blast!
ref="productSelect": Used to get a direct reference to the <select> element in the DOM.
mounted() and beforeUnmount(): Ensures select2 is initialized when the component is ready and destroyed when it's no longer needed.
selectedProductId as internal data: It's generally better to use an internal data property for v-model with third-party libraries that directly manipulate the DOM. You can then watch this property.
watch for selectedProductId: When selectedProductId changes (either internally or via a prop), select2 is programmatically updated.
.on('change', function ( ) { ... }): This is crucial. It listens for select2's change event and updates Vue's selectedProductId accordingly, maintaining the data flow.
You can use Element Plus select components with a filterable option.
Or Vue-multiselect plugin
https://preview.keenthemes.com/metronic8/vue/docs/#/vue-select#example4
To enable a search set searchable: true,
.