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

Dynamic kendo dropdownlist datasource when editing row

1 Answer 739 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
lucerias
Top achievements
Rank 1
lucerias asked on 19 May 2016, 04:40 PM

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.

 

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 23 May 2016, 01:18 PM
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!
 
Tags
DropDownList
Asked by
lucerias
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or