We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Unable to get selected item when suggestion list is having duplicate items

HI Team,


We are having one query regarding the ejs AutoComplete functionality. We are having the data with duplicate key Item (ItemCode) having different Stock Quantity (StockQuantity).

while selecting the row with the particular combination, the first combination is getting autocomplete defiantly.


Below is the sample code.

Ex: Here when we select the fourth row with ItemCode(20060459) and 13 Stock quantity combination, the first row with ItemCode(20060459) and Stock Quantity(5) getting selected.
https://codesandbox.io/s/syncufsion-v18-dropdown-forked-zkee37?file=/src/App.vue

Regards,
Cyril Ovely


3 Replies 1 reply marked as answer

SP Sureshkumar P Syncfusion Team December 1, 2022 01:45 PM UTC

Hi Cyril,

We cannot utilize the duplicate value property to keep component values; instead, we must use the text property to keep track of and permit only unique values to be set to the value property of autocomplete components. The text property can have repeated texts in the same situation; however, the value property can only have unique values to carry out its essential functions.

Regards,

Sureshkumar P



CO Cyril Ovely replied to Sureshkumar P February 27, 2023 04:57 AM UTC

Hi Suresh Kumar,

I appreciate your update. I gave objects in the list array the "uniqId" field. When I turned on filtering for the autocomplete, the "value" property is being filtered instead of the "text" property, which is what I require.

Please let me know how I can apply filtering on the "text" property. CodesandBox attached below for reference.


Syncufsion v18 dropdown (forked) - CodeSandbox


Regards,
Cyril Ovely



SP Sureshkumar P Syncfusion Team February 28, 2023 11:31 AM UTC

Cyril, you can achieve your requirement by using the filtering event.

Find the code example here:

 <ejs-autocomplete

          :dataSource="data"

          :fields="fields"

          :placeholder="watermark"

          :suggestionCount="30"

          :filtering="onComponentFiltering"

          popupHeight="450px"

          :itemTemplate="iTemplate"

          highlight="true"

          allowFiltering="true"

          @change="updateItem"

        ></ejs-autocomplete>

 

 methods: {

    updateItem(event) {

      console.log(

        "Selected Item",

        event.itemData.ItemCode,

        "Selected Item quantity",

        event.itemData.StockQuantity

      );

    },

    onComponentFiltering(args) {

      args.preventDefaultAction = true;

      let query = new Query();

      query = query.where("ItemCode", "contains", args.text, true);

      args.updateData(data, query);

    },

  },

 


Find the modified sample here: https://codesandbox.io/s/syncufsion-v18-dropdown-forked-k4gj7n


Marked as answer
Loader.
Live Chat Icon For mobile
Up arrow icon