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

[Solved] Values in combo box out of step.

6 Answers 101 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alan Mosley
Top achievements
Rank 1
Alan Mosley asked on 02 Sep 2011, 02:54 AM
Hi i have a cobobox using load on demand. I am getting wrong values from. lets say the values are
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

Sort by
0
Georgi Krustev
Telerik team
answered on 02 Sep 2011, 09:49 AM
Hello Alan Mosley,

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 >>

0
Alan Mosley
Top achievements
Rank 1
answered on 03 Sep 2011, 02:35 AM
Thank for your reply, I will make a example if needed, but first i would like to ask a question.
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.
0
Georgi Krustev
Telerik team
answered on 03 Sep 2011, 08:00 AM
Hi Alan,

 
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.

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 >>

0
Alan Mosley
Top achievements
Rank 1
answered on 03 Sep 2011, 09:25 AM
Thanks that is what i had done.
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>

0
Georgi Krustev
Telerik team
answered on 03 Sep 2011, 09:42 AM
Hello Alan Mosley,

 
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")))

Kind 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 >>

0
Alan Mosley
Top achievements
Rank 1
answered on 03 Sep 2011, 10:17 AM
Thank you, i did look, but did not notice .value on server side
Thank you

you guys are the best think to come out of Bulgaria Since Yogurt, or mybe Ivet Lalova
Tags
ComboBox
Asked by
Alan Mosley
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Alan Mosley
Top achievements
Rank 1
Share this question
or