This is a migrated thread and some comments may be shown as answers.
Error when i try to select a new item in Multiselect
5 Answers 69 Views
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 26 Sep 2016, 08:27 PM

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!

 

5 Answers, 1 is accepted

Sort by
0
Martin
Top achievements
Rank 1
answered on 27 Sep 2016, 03:28 PM

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.

0
Martin
Top achievements
Rank 1
answered on 27 Sep 2016, 09:01 PM

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.

 

 

 

0
Veselin Tsvetanov
Telerik team
answered on 28 Sep 2016, 10:15 AM
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
0
Mina
Top achievements
Rank 1
answered on 09 Jul 2019, 11:42 PM
I have the same problem only happens some times, can you send me ticket to see solution?
0
Ivan Danchev
Telerik team
answered on 11 Jul 2019, 02:50 PM
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.
Asked by
Martin
Top achievements
Rank 1
Answers by
Martin
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Mina
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or