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

[Solved] DropDownlist Client Selection bug

3 Answers 47 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.
Mudassar
Top achievements
Rank 1
Mudassar asked on 27 Aug 2011, 05:13 AM
Hi guys,
 I am populating DropDownlist from server side and selects a specific item on client side, function selects required item properly
but does not update the value property so due to this OnChange client side event does not trigger for first time. Please take a look into this.  

@(Html.Telerik().DropDownList()
            .Name("DropDownList_ElegirMapa")
            .BindTo(new SelectList(Model.ElegirMapa, "Value", "Text"))
            .ClientEvents(events => events
                                   .OnChange("DropDownList_ElegirMapa_onChange")
                                   .OnLoad("DropDownList_ElegirMapa_OnLoad"))
            .HtmlAttributes(new { style = "width:400px" })
    )

Client Code 

function DropDownList_ElegirMapa_OnLoad(e) {
    var staticItem = [{ Text: "Por favor Seleccionar", Value: "-1"}];
    var ddlElegirMapa = $(this).data('tDropDownList');
 
    ddlElegirMapa.data = $.merge(staticItem, ddlElegirMapa.data);
    ddlElegirMapa.select(0);
 
 
}

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 29 Aug 2011, 09:44 AM
Hello Muhammad,

 
Unfortunately I was not able to replicate the depicted issue. Check this screen-cast and let me know if I am missing something. It will be really helpful if you can send a simple test project which replicated the described 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
Mudassar
Top achievements
Rank 1
answered on 29 Aug 2011, 10:13 AM
Hi Georgi Krustev,
    Thanks for reply if you first select Chai OnChnage event willnt fire.


Regards,
Mudassir 
0
Georgi Krustev
Telerik team
answered on 30 Aug 2011, 02:07 PM
Hello Muhammad,

 
You will need to use value() method in this case:

var staticItem = [{ Text: "Por favor Seleccionar", Value: "-1"}];
var ddlElegirMapa = $(this).data('tDropDownList');
 
ddlElegirMapa.data = $.merge(staticItem, ddlElegirMapa.data);
ddlElegirMapa.value("-1");

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

Tags
ComboBox
Asked by
Mudassar
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Mudassar
Top achievements
Rank 1
Share this question
or