This is a migrated thread and some comments may be shown as answers.

Numeric value in DropDownList/ComboBox not binding in grid.

5 Answers 383 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 27 Mar 2013, 02:08 PM
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?

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 Mar 2013, 12:07 PM
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!
0
Ben
Top achievements
Rank 1
answered on 29 Mar 2013, 12:45 PM
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
0
Daniel
Telerik team
answered on 02 Apr 2013, 08:53 AM
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!
0
Ben
Top achievements
Rank 1
answered on 02 Apr 2013, 02:41 PM
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.
0
Daniel
Telerik team
answered on 04 Apr 2013, 12:18 PM
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!
Tags
DropDownList
Asked by
Ben
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Ben
Top achievements
Rank 1
Share this question
or