Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Vue Demo | Select with search


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-->


Screenshot:


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


@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,.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(