product A = 1
product B = 11
product C = 12
If i choose A, the value returned is 11
if i choose B or C the value returned is 1
I cant seem to work it out, i am sucpect that it has to do that the is gaps in the order.
when i look at the responce body for the dropdown, the Json looks correct, but looking at the request body when i save the object i can see that the dropdown is returding the wrong value.
Is this a known bug?
i can try to reporduse in a small project, if this is not know.
PS: i did have this happen before, but i thought i solved it by ordering the list before passing to the dropdown.
6 Answers, 1 is accepted
Unfortunately I was not able to observe the depicted issue. My test project is attached to this message. It will be helpful if you can modify it in order to replicate the problem.
Regards,Georgi Krustev
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
I have worked out that my problem is down to selecting the value, If the values in my dropdown are
product A = 1
product B = 11
product C = 12
I am trying to select B by using the value 11, but only works by using value 2
Is this how it is meant to work?
in other words we are selecting by index not value.
This to me is a worry because i have used in other projects assuming we select by value.
If I understand you correctly, you are using select() method and passing value of the item. select() method allows you to pass LI element, index or select item by predicate. If you need to select item by value, use value method. Check this help topic for more information.
Georgi Krustev
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
but i was really after was to set it server side where the model is passed to the drop down, .SelectedIndex(Model), i have now added js to set the value.
@ModelType Integer @(Html.Telerik().DropDownList().Name("MasterId") _ .DataBinding(Function(binding) binding.Ajax().Select("masteridselectlist", "franchisee", New With {.area = "admin"})) _ .SelectedIndex(Model) _ .ClientEvents(Function(events) events.OnLoad("masterIdOnLoad")) _ .ClientEvents(Function(events) events.OnDataBound("masterIdOnDatabound"))) <script type="text/javascript"> function masterIdOnLoad() { $('#MasterId').data('tDropDownList').reload() } function masterIdOnDatabound() { var index = @(Model) $('#MasterId').data('tDropDownList').value(index) }</script>
I believe that Value() method will the better choice in this case:
@(Html.Telerik().DropDownList().Name("MasterId") _ .DataBinding(Function(binding) binding.Ajax().Select("masteridselectlist", "franchisee", New With {.area = "admin"})) _ .Value(Model) _ .ClientEvents(Function(events) events.OnLoad("masterIdOnLoad")) _ .ClientEvents(Function(events) events.OnDataBound("masterIdOnDatabound")))Georgi Krustev
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Thank you
you guys are the best think to come out of Bulgaria Since Yogurt, or mybe Ivet Lalova