Hi,
I try to do that in asp.net mvc : http://dojo.telerik.com/UViSA/13
I want to add item in a multiselect control and after i want to select it.
It work find to add in datasource of my multiselect but i can't select my new item by code (this.value(add);) .
i don't think it the new item the problem because i can't select a existing item. I tried to select a existing element in this event and a had the same error.
I add in attach files a print screen of my error ("Failed to execute 'removeChild' on 'Node' : Parameter 1 is not of type 'Node'....)
This is my code :
@(Html.Kendo().MultiSelectFor(model => model.LesDestinataires) .Name("LesDestinataires") .AutoBind(true) .Filter("contains") .DataTextField("NomComplet") .DataValueField("AdresseCourriel") .Events(e => { e.Change("onChange").Filtering("onFiltering"); }) .DataSource(source => { source.Read(read => { read.Action("ObtenirCourriels", "Assignation"); //read.Type(HttpVerbs.Post); }) .ServerFiltering(false); } ) .HtmlAttributes(new { style = "width:350px;" }) )
after my event : (the problem it at this line : this.value(add);)
function onFiltering(e) { var filter = e.filter; if (filter.value.indexOf(";") > 0) { var newtag = filter.value.replace(";",""); var values = this.value().slice(); //e.preventDefault(); var ajout = {NomComplet: newtag ,AdresseCourriel: newtag }; this.dataSource.add(ajout); this.dataSource.filter({}); var add = [newtag]; if (values.length> 0) { var merge = $.merge(add, values); this.value($.unique(merge)); } else { this.value(add); } this.trigger("change"); //this.dataSource.refresh(); //This don't work } }
My read.action to fill multiselect :
public JsonResult ObtenirCourriels(){ List<Mentore> maSource = db.Mentores.ToList(); var lstMentores = maSource.Take(1).Select(s => new { NomComplet = s.NomComplet_Mentore, AdresseCourriel = s.Courriel_Mentore }); //Take(1) to just fill with one item my multiselect return Json(lstMentores, JsonRequestBehavior.AllowGet);}
Thank for your help!

