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

Add MultiSelect Values that are not in the bound list

1 Answer 448 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Bartley
Top achievements
Rank 1
Bartley asked on 14 Nov 2013, 12:57 AM
I am populating The auto-complete portion of the Multi-Select like below

Controller:
public JsonResult lstNames(string name)
{
    var lstOfNames = db.GetNames.Select(e => new
    {
        name = e.Names
    });
    return Json(lstOfNames , JsonRequestBehavior.AllowGet);
}

Razor:

@(Html.Kendo()
      .MultiSelect()
      .Name("names")
      .AutoBind(true)
      .Placeholder("Select names...")
      .DataTextField("name")
      .DataSource(source =>
      {
          source.Read(read =>
          {
              read.Action("lstNames", "ListNamesView");
          })
                .ServerFiltering(true);
      })
 
)

I was wondering is it possible to bind the value to a list that is not in the auto-complete list and also be able to type a new name in as the value?


1 Answer, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 15 Nov 2013, 02:24 PM
Hello Bartley,

You cannot enter any free text, however you can add/insert new items to the dataSource that the multiselect uses and thus they will become part of the collection as the other initial items.

e.g.

http://jsbin.com/uWEvulEn/2/edit

You can also set the value programatically with the value method.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MultiSelect
Asked by
Bartley
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or