Disable DropDownListFor on Edit (not at New)

6 posts, 0 answers
  1. Robert Madrian
    Robert Madrian avatar
    154 posts
    Member since:
    Apr 2003

    Posted 05 Dec 2015 Link to this post

    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) {
     
             ????
         }
     
     }

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1941 posts

    Posted 08 Dec 2015 Link to this post

    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
  3. Robert Madrian
    Robert Madrian avatar
    154 posts
    Member since:
    Apr 2003

    Posted 08 Dec 2015 in reply to Boyan Dimitrov Link to this post

    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?

     

  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1941 posts

    Posted 10 Dec 2015 Link to this post

    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
  5. Cat
    Cat avatar
    2 posts
    Member since:
    May 2015

    Posted 19 Dec 2016 in reply to Boyan Dimitrov Link to this post

    How would this be done for MVC/razor configuration?
  6. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2046 posts

    Posted 21 Dec 2016 Link to this post

    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.
Back to Top