Dynamic kendo dropdownlist datasource when editing row

2 posts, 0 answers
  1. lucerias
    lucerias avatar
    16 posts
    Member since:
    Nov 2011

    Posted 19 May Link to this post

    I have customer grid, when user double clicks the row, the custom pop up editor will be shown, there is drop down to show list interest but i need to remove the interest of current selected customer row from the viewdata by using interest id. 

    Customer Model:

        public class CustomerModel
        {

            [Display(Name = "Customer ID")]
            public int CustomerID { get; set; }

            [Display(Name = "Interest ID")]
            [UIHint("InterestDropDown")]
            public int InterestID { get; set; }

    }

     

    InterestDropDown.cshtml

    @model int

    @(
         Html.Kendo().DropDownListFor(m => m)
                .BindTo((System.Collections.IEnumerable)ViewBag.InterestList)
                .DataValueField("InterestID ")
                .DataTextField("InterestName")
                .OptionLabel("Please select")
    )

    Customer editor template

    <table class="popup-layout-tbl" style="display: table;">
    <tbody>

    <tr id="trAppID">
    <td>
                    <div class="k-edit-label popup-label">
                        @Html.LabelFor(model => model.CustomerID , new { @class = "popup-label-text" } )
                    </div>
                    <div>
                        @Html.TextBoxFor(model => model.CustomerID , new { @readonly = true, @class = "popup-input" })
                        @Html.ValidationMessageFor(model => model.CustomerID )
                    </div>
    </td>
    </tr>

    <tr>
    <td>
                    <div class="k-edit-label popup-label">
                        @Html.LabelFor(model => model.InterestID , new { @class = "popup-label-text" } )
                    </div>
                    <div>
                        @Html.EditorFor(model => model.InterestID , new { @class = "popup-input" })
                        @Html.ValidationMessageFor(model => model.InterestID  )
                    </div>
      
    </td>
    </tr>

    </tbody>
    </table>

     

    Thanks.

     

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 23 May Link to this post

    Hello,

    If you would like to filter (reduce) the items in the DropDownList widget when in edit mode, then you will need to do the following things: This approach allows to remove of unwanted items from the data source.

    Note that the widget cannot select items that are not present in the source. If the item you would like to remove is selected, then it could be lost.

    Regards,
    Georgi Krustev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top