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

[Solved] DropDownList OnChange event fires for all the actions in the telerik window

1 Answer 97 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.
Sampath
Top achievements
Rank 1
Sampath asked on 16 Aug 2012, 06:29 AM
Dear Telerik Team,

In my telerik window, I am loading a dropdownlist based on another dropdownlist onchange event (It works fine). But what ever the action I do telerik window the onchange event of the dropdown is firing.

Based on this dropdown list change I am loading another dropdownlist,

@(Html.Telerik().DropDownListFor(m => m.VLC_COST_GEN)

 .Placeholder("Select General Cost..")

 .ClientEvents(events => events

 .OnLoad("Areas.APUIAdmin.CostCodes.loadGeneralCost")

 .OnChange("Areas.APUIAdmin.CostCodes.loadCostCategoryOnGeneralChange"))

 .HtmlAttributes(new { style = "width:70%" })

JS Code I have used to load the another dropdownlist on change,

loadCostCategoryOnGeneralChange: function (e) {

$.getJSON("/APUIAdmin/CostCodes/GetReferenceDataOnChnage?strDomian=VLC_COST_CAT" + "&strHighVal=" + e.value, function (data) {

$("#VLC_COST_CAT").data("tDropDownList").dataBind(data);

$("#VLC_COST_CAT").data("tDropDownList").select(0);

});

}

The second dropdownlist which I am loading in the onchange of first one,

@(Html.Telerik().DropDownListFor(m => m.VLC_COST_CAT)

 .Placeholder("Select Cost Category")

 .BindTo(new SelectList(Starnet.Web.AP.UIAdmin.ReferencedData.GetReferenceData("VLC_COST_CAT", Model.VLC_COST_GEN), "RV_LOW_VALUE", "RV_MEANING")) 

 

.ClientEvents(events => events

.OnChange("Areas.APUIAdmin.CostCodes.loadServiceTypeOnCategoryChange"))

.HtmlAttributes(new { style = "width:70%" })

 )

 }

 

 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 Aug 2012, 05:56 AM
Hello Sampath,

I am not sure if I exactly understand the issue but the OnChange event will be triggered after any action when using the select method. Since the new item is only selected and the value is not change, the OnChange event will be thrown after the control loses focus. In order to avoid this you should use the value method with the value from the first item.
If this is not the problem you are experiencing, please send a sample project so I can check the exact setup and investigate further.

Regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
ComboBox
Asked by
Sampath
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or