Disable DropDownListFor on Edit (not at New)

4 posts, 0 answers
  1. Robert Madrian
    Robert Madrian avatar
    93 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
    1746 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. UI for ASP.NET MVC is VS 2017 Ready
  4. Robert Madrian
    Robert Madrian avatar
    93 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?

     

  5. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready