Hello,
I want to disable my ForeignKey DropDownListFor colums on edit but let them editable on new row...
how to find the DropDownList in the edit event and disable the dropdownlist?
function grid_edit(e) {
if (e.model.isNew() == false) {
????
}
}
5 Answers, 1 is accepted
Hello Robert Madrian,
One possible solution is to find and disable the DropDownList widget if the model is not a new one. Please refer to the http://dojo.telerik.com/uQeNi example for reference.
Regards,
Boyan Dimitrov
Telerik
It is different in the grid because there is no <select> element - in my grid the ForeignKey dropdownlist is only a <span> - see attached picture - how to find and disable this element?
Hello Robert Madrian,
From the screenshot it seems that it is an input element, no select element. Both elements could be used in order to initialize Kendo UI DropDownList widget. Your edit handler should look like:
edit:
function
(e){
var
ddlEl = e.container.find(
"input[name='LehrBeruf_Id']"
);
if
(!e.model.isNew() && ddlEl.length > 0){
var
ddl = e.container.find(
"input[name='LehrBeruf_Id']"
).data().kendoDropDownList;
ddl.enable(
false
);
}
},
Regards,
Boyan Dimitrov
Telerik
There will be no difference in the approach for the MVC wrapper, except for attaching the event handler:
.Events(ev=>ev.Edit("edit"))
...
<
script
type
=
"text/javascript"
>
function edit(e) {
//...
}
Hope this helps.
Regards,
Konstantin Dikov
Telerik by Progress