Error when i try to select a new item in Multiselect

4 posts, 0 answers
  1. Martin
    Martin avatar
    7 posts
    Member since:
    May 2016

    Posted 26 Sep Link to this post

    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!

     

  2. Martin
    Martin avatar
    7 posts
    Member since:
    May 2016

    Posted 27 Sep Link to this post

    Ok... my code was good...

    The problem was i had a old telerik asp.net Library (2015.3.1111) and i update it to 2016.3.914.

    Now i can add and select the new item. But the filter Windows don't close (see my attach files).

    It will close if i had that line : this.dataSource.refresh();  but i will have this error : this.dataSource.refresh is not a function.

    if i want to close it i have to do a .close function but i don't want to close the dropdown list but just the filter list.

    Thank to help me.

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Martin
    Martin avatar
    7 posts
    Member since:
    May 2016

    Posted 27 Sep Link to this post

    this.dataSource.refresh(); only work partially.... it will do what i want but throw a javascript error. If i put in in a try/catch it stop to work.

    when i don't have this line...if i leave the multiselect and go back in...i have a error (typeError: cannot read property 'value' of undefined) it like i lost my new rows.

    in this exemple .refresh() work : http://dojo.telerik.com/UViSA/13

    i tried in other project with no sql data and i have the same error.

     

     

     

  5. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    290 posts

    Posted 28 Sep Link to this post

    Hi Martin,

    I have answered to your question in the support ticket that you have opened. I suggest you to continue the further discussion on this matter there and close this forum thread.

    Regards,
    Veselin Tsvetanov
    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready