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

Dropdown template using distinct strings found in rows

Is it possible to have a cell template utilize a dropdown that, when opened, shows a listing of unique strings found within the column?  For example, if a grid was showing 3 rows and one of the columns was bound to a string called 'Ingredient'.  And out of those 3 rows, 2 of the rows have an Ingredient value of 'egg' and the other is set to 'flour'.  When the dropdown opens, I would like to show 2 values 'egg' and 'flour'.  But the dropdown would also allow the user to type in something different.

It would have to be dynamic in that it would look at all items in the column before popping up so that when users add another row with another value, the next time the dropdown opens, it would include that new value.


- Jeff

6 Replies

VB Vinitha Balasubramanian Syncfusion Team December 6, 2022 10:15 AM UTC

Hi Jeff,

Greetings from Syncfusion support.

Query1 : Dropdown template using distinct strings found in rows

Yes,  by default when perform edit action using dropdown it will shows only distinct values from the respective columns. We have attached the sample for your reference.

Sample :  https://stackblitz.com/edit/react-v94tiu-fnxajk?file=index.js,data.js

Query2 : If users add another row with another value, the next time the dropdown opens, it would include that new value.

By default, dropdown values show the existing values from the dataSource on performing edit action in the Grid component. Before proceeding your query, kindly share the below details with us which is more helpful to proceed your query further.

  • Please share your exact requirement with detailed description.
  • Please share the video demo of your reported problem.
  • Please share the complete grid code file and package.json file.


Vinitha Balasubramanian   

JV Jeff Voigt December 6, 2022 06:50 PM UTC

So, the demonstration does, in fact, show a dropdown of the distinct values found within the rows.  However, the user is not able to type in something different if what they see is not in the list.  I would need the ability to allow the user to freely type as an additional option.

JC Joseph Christ Nithin Issack Syncfusion Team December 12, 2022 07:53 PM UTC


  Based on your requirement, you want to have a dropdown with a list of options and you also want to type some other options which is not in the list. Your requirement can be achieved by rendering a combo box instead of the dropdown list. Refer the below documentation for more details on combobox.



JV Jeff Voigt December 12, 2022 08:38 PM UTC

That's great, but you just referenced an example of a standalone combobox component instead of how it would be used within a grid for my specific use case.

VB Vinitha Balasubramanian Syncfusion Team December 14, 2022 03:55 PM UTC

Currently we are validating the reported scenario “Dropdown template using distinct strings found in rows” at our end. So we will update further details shortly. Until then we appreciate your patience.

VB Vinitha Balasubramanian Syncfusion Team December 27, 2022 12:55 PM UTC

As per your requirement we have prepared a sample with combo Box to add a custom value to the dataSource. You can add the custom value using “filtering” event of comboBox. The “onFiltering” function is called when the customer searches for an item in the ComboBox or enters a custom value. It filters the comboBoxData based on the search string and updates the ComboBox with the filtered data. If the customer enters a value that is not in the list, a button is displayed in the ComboBox popup that allows the customer to add the custom value to the list. When the button is clicked, the custom value is added to the comboBoxData and selected in the ComboBox. Here is an example of how to implement this:





        fields={{ text: 'name', value: 'id' }}


        ref={(ComboBox) => {

          this.listObj = ComboBox;





        placeholder="Select a country"


// set the template content when the typed character(s) is not present in the list

template =

    '<div id="nodata"> No matched item, do you want to add it as new item in list?</div> <button id="btn" class="e-control e-btn">Add New Item</button>';


onFiltering = (e) => {

    let query = new Query();

    // frame the query based on search string with filter type.

    query =

      e.text !== '' ? query.where('Name', 'startswith', e.text, true) : query;

    // pass the filter data source, filter query to updateData method.

    e.updateData(this.comboBoxData, query);

    let proxy = this;

    if (document.getElementById('nodata')) {

      // bind click event to button which is shown in popup element when the typed character(s) is not present in the list

      document.getElementById('btn').onclick = function () {

        // get the typed characters

        let customValue = document.getElementById('customvalue').value;

        // make new object based on typed characters

        let newItem = { id: customValue, name: customValue };

        // new object added to data source.


        // close the popup element.


        // pass new object to addItem method.


        // select the newly added item.

        proxy.listObj.inputElement.value = customValue;




Sample : https://stackblitz.com/edit/react-v94tiu-lahkk7?file=index.js,data.js

API : https://ej2.syncfusion.com/react/documentation/api/combo-box/#filtering

Live Chat Icon For mobile
Up arrow icon