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

Set value when DropDownList is disabled

1 Answer 708 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Heiko
Top achievements
Rank 1
Iron
Veteran
Heiko asked on 04 Sep 2019, 12:59 PM

I create a disabled DropDownList with the following code:

<kendo-dropdownlist for="FreezeVM.Year" class="form-control"
                    datatextfield="Text"
                    datavaluefield="Value"
                    height="290"
                    enable="false"
                    bind-to="Model.YearList">
</kendo-dropdownlist>

Based on another DropDownList I change the value of this list:

function onTargetTypeChange(e) {
    var targetValue = this.value();
    var currentYear = new Date().getFullYear();
    var yearDrop = $("#FreezeVM\\.Year").data("kendoDropDownList");
    if (targetValue === "6" || targetValue === "7") {
        yearDrop.value(currentYear + 1);
    }
    else {
        yearDrop.value(currentYear);
    };
};

 

The change is reflected on the UI, but not on the underlying Model which still has the old value. As soon as I enable the DropDownList everything works fine. What I expect is that the value gets changed no matter if the dropdown is enabled or disabled.

Regards
Heiko

 

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 09 Sep 2019, 10:32 AM

Hi Heiko,

Based on the provided code, I've tried to reproduce the reported issue but I am unable to do it. 

Attached to my reply you will find a project in which there are two DropDownLists. The first one has values range from 1 to 7 and is enabled. The second one is disabled and has values ranging from 2016 to 2021. Based on the selected item in the first DropDownList, the value of the second one is being changed using the provided onTargetTypeChange function. 

Under the two DropDownLists, there is a button that alerts the current value of the disabled DropDownList directly from its DataSource. Using the provided instruction I am trying to reproduce the reported issue but the value of the disabled DropDownList is being changed and the displayed value is the expected one. 

Can you please modify the attached project in a way the issue you report could be reproduced and send the project back to me? Having the issue reproduced, I will be able to investigate what is triggering it and give a possible solution for the case. 

Regards,
Petar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownList
Asked by
Heiko
Top achievements
Rank 1
Iron
Veteran
Answers by
Petar
Telerik team
Share this question
or