Hello EveryOne,
I'm trying to change the dataSource of a MultiSelect widget.
This is my MultiSelect (in my CustomEditor):
@(Html.Kendo().MultiSelectFor(model => model.Person) //.Name("FirmaAutoSelect") .DataTextField("Name") .MaxSelectedItems(1) .AutoWidth(true) .HtmlAttributes(new { style = "width:100%" }) .Events(eve => { eve.Open("onOpen_Person"); }) //.ValuePrimitive(true) .DataSource(source => { source.Custom() //.ServerFiltering(true) .Type("aspnetmvc-ajax") .Transport(transport => { transport.Read("Read_Personen", "Person"); }) .Schema(schema => { schema.Data("Data") .Total("Total") .Errors("Errors"); }); }) )
and i tried in the onOpen_Person function this code :
var person_mult = $("#Person").data("kendoMultiSelect"); var dataSource = new kendo.data.DataSource({ //batch: true, transport: { read: { url: "/Person/AlleOderFirma_Personen", dataType: "json" }, // } //}); parameterMap: function (options, operation) { if (operation !== "read" && options.models) { return { models: kendo.stringify(options.models) }; } } }, schema: { model: { id: "Sid_personen", fields: { Sid_personen: { from: "Sid_personen" } } } } }); person_mult.setDataSource(dataSource);
Now this shows just one item and it's undefined !!
I console.Logged the dataSource and i saw that the "Sid_personen" is undefined .. but in "_data" i found all the items i need .. but it doesn't show them ..
in the attached picture you can see the consoleLogged DataSource.
and this is my ActionMethod:
public ActionResult AlleOderFirma_Personen([DataSourceRequest]DataSourceRequest request){ //string g = Id_Firma; using (var db = new cRM_FM_v2_KARAMEntities()) { IQueryable newQuery = db.PERSONEN.ToList().Select(prs => new PersonViewModel() { Sid_personen = prs.SID_PERSONEN, Name = prs.NAME, Vorname = prs.VORNAME, Recid_firmen = prs.RECID_FIRMEN, Crmusername = prs.CRMUSERNAME }).AsQueryable(); return Json(newQuery.ToDataSourceResult(request), JsonRequestBehavior.AllowGet); }}