Error when i try to select a new item in Multiselect

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

    Posted 26 Sep 2016 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 2016 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. Martin
    Martin avatar
    7 posts
    Member since:
    May 2016

    Posted 27 Sep 2016 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.

     

     

     

  4. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1039 posts

    Posted 28 Sep 2016 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
  5. Mina
    Mina avatar
    9 posts
    Member since:
    Oct 2015

    Posted 09 Jul in reply to Veselin Tsvetanov Link to this post

    I have the same problem only happens some times, can you send me ticket to see solution?
  6. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1749 posts

    Posted 11 Jul Link to this post

    Hello Mina,

    I will quote Veselin's reply in the support ticket related to this forum thread:

    The DataSource object does not have a refresh() method, which is the reason for the observed error. I would recommend you to remove that call from your implementation and add the following call on the first line in your if statement:
    if (filter.value.indexOf(";") > 0) {
        e.preventDefault();
        .........
    }
    Here you could find a modified version of the discussed Dojo sample.

    In case your scenario and the issue you are facing are different, open a new thread and demonstrate/elaborate more on the problem.

    Regards,
    Ivan Danchev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top