user3112260
user3112260

Reputation: 43

How can this KendoUI DropDown list be filtered or restricted with a where clause?

I am trying to restrict the options in the dropdownlist and I would like to do this at the view level. Thanks in advance!

<div class="toolbar">
    <label class="category-label" for="category">Update By Service Tier:       </label>
   @(Html.Kendo().DropDownList()
        .Name("AvailableServiceTiers")
        .OptionLabel("Select")
        .DataTextField("Name")
        .DataValueField("ServiceTierId")
        .AutoBind(false)
        .Events(e => e.Change("changeSelectedServiceTier"))
        .DataSource(ds =>
        {
        ds.Read("GetCustomerServiceTierNameList", "Descriptions", new {customerId = Model.OrganizationId });
        })
        ) 
  <a id="SaveBatchServiceTestBtn" class="k-button k-button-icontext k-grid-save-changes" href="javascript:void(0)"><span class="k-icon k-update"></span>  Save  </a>
</div>

Upvotes: 0

Views: 54

Answers (1)

Hadee
Hadee

Reputation: 1402

It is better to have your data populating separated from your view. In controller create something like:

 ViewBag.AvailableServiceTiers= ds.Read("GetCustomerServiceTierNameList).Where();

Then in your view you can have:

    @(Html.Kendo().DropDownList()
    .Name("AvailableServiceTiers")
    .OptionLabel("Select")
    .DataTextField("Name")
    .DataValueField("ServiceTierId")
    .BindTo(AvailableServiceTiers)

Upvotes: 1

Related Questions