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

How to bind initial value for ComboBox with server filtering?

1 Answer 182 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
StefanDV
Top achievements
Rank 1
StefanDV asked on 25 Jul 2016, 10:12 AM

Hi

 

I am using databinding in my MVC view with ComboBoxFor (see sample below).

This works great when I am using this the first time (new record). However, when I want to Edit my entity, I want that upon opening the view, the ProductName is already there. How to accomplish this? If I set the .Text property then this is showed, but the binding gets lost when I save. Is there a way set force a call to the controller to get the ProductName based upon the bound MyProductId?

 

@(Html.Kendo().ComboBoxFor(m => m.MyProductID)
          .Placeholder("Select product")
          .DataTextField("ProductName")
          .DataValueField("ProductID")
          .HtmlAttributes(new { style = "width:100%;" })
          .Filter("contains")
          .AutoBind(false)
          .MinLength(3)
          .DataSource(source => {
              source.Read(read =>
              {
                  read.Action("GetProducts", "Home");
              })
              .ServerFiltering(true);
          })
    )

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 27 Jul 2016, 07:16 AM
Hello Stefan,

Since you mentioned new records and editing I guess the combobox is integrated as an editor template inside a databound control (e.g., a grid). If that is the case you can examine the samples below which illustrate similar approaches:

    - Grid editing using ComboBox with remote binding and filtering
    - Using Cascading DropDownLists as custom editors for Grid InCell edit mode
    - Grid to handle cascading dropdownlists with popup or inline editing mode
   -  Grid / ForeignKey column

Regards,
Danail Vasilev
Telerik by Progress
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
Tags
ComboBox
Asked by
StefanDV
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or