Allow nulls ( and not have them converted to the empty string)

3 posts, 1 answers
  1. Scott Waye
    Scott Waye avatar
    111 posts
    Member since:
    Nov 2009

    Posted 07 Sep Link to this post

    Hi,

    I have code similar to this:

    http://dojo.telerik.com/OfiMU/7

    I want to bind the dropdownlist to a nullable field on the model.  The user should be able to select a value from the list or the select the first optionLabel in order to put the value back to null.  So I added the k-option-label with a value field of null, however when selecting this value in the drop down the model is set to the empty string.  This is a problem as when saved to the database it causes a foreign key exception.   How do I set up the dropDownList to allow it to bind to nullable properties on the model?

     

    Thanks

  2. Answer
    Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 09 Sep Link to this post

    Hello Scott,

    The ng-model directive works with the value of the underlying SELECT element, which is empty string (""). As a result when the option label is selected, the model value is empty string. Unfortunately, we cannot keep the "null" value as values of the OPTION element is always string.

    The solution is either to avoid depending on the null or use k-ng-model:

    http://dojo.telerik.com/OfiMU/8

    Regards,
    Georgi Krustev
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Kendo UI is VS 2017 Ready
  4. Scott Waye
    Scott Waye avatar
    111 posts
    Member since:
    Nov 2009

    Posted 09 Sep in reply to Georgi Krustev Link to this post

    Thanks, I should have tried that.
Back to Top