Numeric value in DropDownList/ComboBox not binding in grid.

6 posts, 0 answers
  1. Ben
    Ben avatar
    4 posts
    Member since:
    Jan 2012

    Posted 27 Mar 2013 Link to this post

    DropDownLists (or ComboBoxes) for numeric members on the model do not post their value when used in a grid. I have attached a sample project. Is there anything I am doing wrong or need to do differently in order to accomplish this?
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 29 Mar 2013 Link to this post

    Hello Ben,

    When the initial value is null, the value binding will attempt to update the field with the selected item from the dropdown/combobox and because the fields are numbers, they will not be updated correctly. You should either use the approach shown in the custom editor demo and bind the column to an object or create a custom binder as demonstrated in this code library.

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Ben
    Ben avatar
    4 posts
    Member since:
    Jan 2012

    Posted 29 Mar 2013 Link to this post

    Hi Daniel,

    Thanks for your response. Does "bind it to an object" mean something different than how it was done in my sample project? Do you guys have an estimate of when this will be fixed?

    Thanks again,
    Ben
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 02 Apr 2013 Link to this post

    Hello Ben,

    This behavior is by design as specified in the value binding documentation. 
    Regarding you question about binding the combobox/dropdown to an object - you should add an object to your viewModel that holds the text and value, and bind the column to the object instead. I updated the project to demonstrate this approach for one of the properties.

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Ben
    Ben avatar
    4 posts
    Member since:
    Jan 2012

    Posted 02 Apr 2013 Link to this post

    So you are telling me that by design your dropdown controls bind incorrectly to numerical values when used in a grid, even though they work outside of a grid? What is the benefit of behaving differently inside and outside of a grid? Has ForeignKey been deprecated since this new way breaks it? This all worked in the Telerik controls, so it seems weird that it would be done so differently in Kendo. Do you mind providing a link to the documentation that describes this behavior?

    The edit mode of the grid in my actual project is GridEditMode.PopUp, I don't know if that makes a difference. Either way, none of these solutions are really acceptable. They make the dropdown controls, and due to consistency, the entire suite, really inconvenient to use.
  7. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 04 Apr 2013 Link to this post

    Hello Ben,

    The behavior is explained in the value binding documentation from my first reply and is consistent when using the MVVM binding in or outside of the Grid. As mentioned in my first reply you can avoid it with a custom value binder as demonstrated in the code-library. The approach will be the same for popup editing mode. I attached the code-library project modified to use popup editing.

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready