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

Disable DropDownListFor on Edit (not at New)

5 Answers 702 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Robert Madrian asked on 05 Dec 2015, 07:10 PM

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

Sort by
0
Boyan Dimitrov
Telerik team
answered on 08 Dec 2015, 01:01 PM

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 08 Dec 2015, 02:23 PM

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?

 

0
Boyan Dimitrov
Telerik team
answered on 10 Dec 2015, 12:27 PM

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Cat
Top achievements
Rank 1
answered on 19 Dec 2016, 01:59 PM
How would this be done for MVC/razor configuration?
0
Konstantin Dikov
Telerik team
answered on 21 Dec 2016, 07:02 AM
Hi Cat,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Answers by
Boyan Dimitrov
Telerik team
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Cat
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or