Please consider the following dojo :
The issue is on the first field "ProductID" when using "number" as the type of its "id".
Steps to reproduce the issue :
1- Create new record
2- Select entry "aaa" or "bbb"
3- Validate entry
4- Edit Entry again and select option label "select..."
5- Validate entry
6- Edit entry again and select "aaa" or "bbb"
7- Validate and you can see that current value is null and you cannot select another value anymore.
Please tell me what I'm doing wrong. Note that this works well when using "string" type.
5 Answers, 1 is accepted
Thank you very much for the provided Dojo to illustrate your scenario.
The only ingredient that is missing is the optionLabel. The option label should match the format of the data so that everything works correctly. In this case, when the Kendo UI DropDownList data source data items are objects with an id of type "number" and text of type "string", you should declare the option label in the same manner:
If you do not wish to show 0 in the Kendo UI ListView when no selection is made, you can add a condition to the template:
Here is the updated Dojo for your reference:
More about the option label is available in the API of the Kendo UI DropDownList here:
Let me know if you have further questions.
Thank you for your prompt response.
I already tried your solution with option-label as an object. It works but it won't if the field has to be mandatory.
Adding "required" attribute won't work because the value for select is not null.
Any clue ?
You are correct that in the case where the field property is required, having its default value as a number will not trigger the browser validation.
What you can do is create a custom validation rule as part of the schema field declaration and check if the value is "0". If this is the case, return false and the Kendo UI Validator will kick in:
Here is the updated Dojo for your convenience:
Let me know if there is anything else I can help you with.
Thank you so much for your workaround. It works great.
Let me ask you 2 questions :
1) About that issue, is it a bug or not ?
Another thing that could be great is to be able to define the errorTemplate at the same point.
Anyway, thanx again for your help.
Thank you for the feedback on the model documentation.
I will discuss it with the team and see if we can extend it with the referenced validator if it seems unclear to you, it is definitely worth checking it out. Also, if you wish to contribute yourself, you are welcome to do that - here is how:
Finally - the matter at hand - it is possible to achieve the functionality required without a custom validation by setting the id to an empty string or null, apologies for missing this option out in my previous response.
Here is the updated runnable demo:
More information about it is available in this forum thread: