Column editor with combobox/autocompete shows undefined

1 Answer 232 Views
AutoComplete ComboBox Editor Grid
Ionela
Top achievements
Rank 1
Ionela asked on 06 May 2021, 12:06 PM | edited on 07 May 2021, 12:11 PM

Hello. I am using a custom column editor as shown in your example : https://docs.telerik.com/kendo-ui/knowledge-base/custom-editor-autocomplete. Even in the example that you provided, if I type a value that is not in the list, on focus out the field will display "undefined" and will remain this way even if i try to select another value. Is there a fix for this situation? Thank you in advance :)

I attached a screenshot from your working example.

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 11 May 2021, 06:15 AM

Hello, Ionela,

You can change the column template as below so that if you select an item that is not in the AutoComplete dataSource, the value of the cell will be an empty sting instead of undefined.

columns: [{
            field: "user",
            template: "#:user.userName != undefined ? user.userName : '' #",
            title: "User Name",
            //editor: userNameComboBoxEditor
            editor: userNameAutoCompleteEditor
        }, {
            field: "productName",
            title: "Product Name"
        }, {
            field: "amount"
        }]

Here is the modified example for reference.

Let me know how that works for you.

Regards,
Martin
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Ionela
Top achievements
Rank 1
commented on 11 May 2021, 07:32 AM

Hello, Martin. Thank you for the response. Indeed, changing the template works for not having undefined as cell value and that''s great :) , but that doesn't fix the next step. Once you failed in typing a value that is in the list, you are no longer able to select another one and you can only see the cell value while you have the focus on it. If you focus another cell, the value is replaced by the empty string. Maybe you have some advice for that also?
Martin
Telerik team
commented on 14 May 2021, 06:50 AM

Hello, Ionela,

Could you please share the steps I need to make to observe the problem as well as what the result should be? Once I am more familiar with the matter, I will be happy to assist you.

Regards,

Martin

Ionela
Top achievements
Rank 1
commented on 18 May 2021, 07:46 AM

Hello! Yes, happy to.
1. type a value that is not in the list (e.g. Fres instead of Fred).
2. focus out of the field and move the focus in the cell bellow.
3. go back to the cell where you now have an empty string (it used to be undefined before your suggestion for changing the template) and select a value from the list (Fred or Bert - it doesn't matter).
4. move the focus again on the cell bellow and you still have an empty string (or an undefined) value in that first cell.
5. focus back to the first cell, you can see the value selected (this only happens when the cell is focused and it disappears once you focus out).
Thank you for your response ,
Ionela
Martin
Telerik team
commented on 21 May 2021, 07:00 AM

Thank you for the additional information. If I understand correctly, the problem is that the Grid still displays empty string even if you select a valid item from the AutoComplete. Could you please take a look at this modified version of the example, to see if it will be more suitable to your needs? Let me know how that works for you.
Ionela
Top achievements
Rank 1
commented on 24 May 2021, 07:11 AM

Works like a charm ! Thank you so much for your help. Have a great day, Martin!
Tags
AutoComplete ComboBox Editor Grid
Asked by
Ionela
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or