This is a migrated thread and some comments may be shown as answers.
Paste in MultSelect Error
7 Answers 8 Views
This is a migrated thread and some comments may be shown as answers.
Mina
Top achievements
Rank 1
Mina asked on 19 Aug 2019, 10:43 PM

I have a multiSelect and want to have paste to select, nut some times I am getting this error, 

Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.

function ParsePaste(inputSent) {

try {

//console.log($(CtrlName).data("kendoMultiSelect").dataSource.data().length);
var originalArray = $(CtrlName).data("kendoMultiSelect").value();
var pidArray = inputSent.val().trim().replace(/\s*,\s*|\s*;\s*|\s+/g, ",").split(",");

if (originalArray.length >= 1) {
for (var i = 0; i < originalArray.length; i++) {
pidArray.push(originalArray[i]);
console.log(pidArray);
}
}
inputSent.val("");
setTimeout(function () {
try {
$(CtrlName).data("kendoMultiSelect").value(pidArray);
} catch (ex) {
alert('try again!');
console.log(ex); 
}
setTimeout(function () {
try {
var newArray = $(CtrlName).data("kendoMultiSelect").value();
Array.prototype.diff = function (a) {
return this.filter(function (i) { return a.indexOf(i) < 0; });
};
if (pidArray.diff(newArray).length > 0) { aeriesWin.prototype.alert(pidArray.diff(newArray) + " not found!"); }

} catch (ex) { alert('try again!'); }
}, 250);

}, 200);
} catch (ex) {
//alert("2:" + ex);
alert('try again!');
}
}


$(function () {

$(document).on('paste', '.k-multiselect-wrap input:visible', function (e) {

setTimeout(function (e) {

ParsePaste($('.k-multiselect-wrap input:visible'));
}, 50);
});

$(document).on('keyup', '.k-multiselect-wrap input:visible', function (e) {

if (e.which == 13) {
var originalArray = $(CtrlName).data("kendoMultiSelect").value();
 originalArray.push($(this).val());
setTimeout(function () {
$(CtrlName).data("kendoMultiSelect").value(originalArray);
}, 250);
}

});
// $("#" +  ).siblings("div").find("input[aria-owns^=" +msStudents+"]").keyup(function (e) {
//if (e.which == 13) {
//alert('xxx');
//}

//});

})

7 Answers, 1 is accepted

Sort by
0
Mina
Top achievements
Rank 1
answered on 19 Aug 2019, 10:45 PM
try {
$(CtrlName).data("kendoMultiSelect").value(pidArray);
} catch (ex) {
alert('try again!');
console.log(ex); 
}
0
Mina
Top achievements
Rank 1
answered on 19 Aug 2019, 10:47 PM

@(Html.Kendo.MultiSelect().Name(CtrlName) _
.HtmlAttributes(New With {.style = "width: " + Width + ";display:inline-block;"}) _
.DataTextField("ID") _
.DataValueField("ID") _
.HeaderTemplate("<div class='dropdown-header k-widget k-header'><span class='col stu_col1'>ID</span><span class='col stu_col2'>Last Name</span><span class='col stu_col3'>First Name</span><span class='col stu_col4'>Middle</span><span class='col stu_col5'>Grade</span><span class='col stu_col6'>Gender</span></div>") _
.ItemTemplate("<div class='dropdown'><span class='k-state-default col stu_col1 '>#:ID#</span><span class='k-state-default col stu_col2'>#:LastName#</span><span class='k-state-default col stu_col3'>#:FirstName#</span><span class='k-state-default col stu_col4'>#:MiddleName#</span><span class='k-state-default col stu_col5'>#:Grade#</span><span class='k-state-default col stu_col6'>#:Gender#</span></div>") _
.FooterTemplate("").Filter("contains") _
.MaxSelectedItems("900").Placeholder("Enter Student names or IDs...(type 3 char at least)") _
.Events(Sub(e) e.Open("onOpen").Filtering("onFiltering")) _
.AutoBind(True).MinLength(3).Delay(0).HighlightFirst(True) _
.DataSource(Sub(source)
source.Read(Sub(read)
read.Action("GetAllActiveStudentsForSchool", "StudentWidgets", New With {.Area = "Widgets"})
End Sub) _
.ServerFiltering(False)

End Sub))

0
Dimitar
Telerik team
answered on 21 Aug 2019, 11:18 AM
Hi Mina,

There is an existing forum thread where implementing a similar functionality to the one described is discussed in greater details:


As the MultiSelect widget does not provide a built-in option to handle this, I would suggest utilizing the approach provided in the last response of the above-linked thread. With it, when a text is pasted in the MultiSelect and if some of the separated values are existing in the widget data source, then they are being selected. 

The above can also be observed in the following Dojo example:


To test is, simply copy the following text "0001X, 0003X, 0005X" and paste it in the MultiSelect. As a result, the corresponding values are being selected in the widget.

Regards,
Dimitar
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.
0
Mina
Top achievements
Rank 1
answered on 21 Aug 2019, 04:51 PM
I saw it, it didn't work. when I paste it, just showing a message "data pasted".
0
Mina
Top achievements
Rank 1
answered on 21 Aug 2019, 04:53 PM
It works if paste one at a time, I want to paste more than one item separated by comma or semicolon. 
0
Accepted
Dimitar
Telerik team
answered on 23 Aug 2019, 06:20 AM
Hello Mina,

Here is an updated Dojo example where the alert is removed:


With it, when a comma separated values are pasted in the MultiSelect, if there are corresponding data items in the widget data source, then the items are selected. To test this, simply copy the following:
0001X, 0003X, 0005X

and then paste it in the MultiSelect. As a result, the three values will be selected.

Regards,
Dimitar
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.
0
Mina
Top achievements
Rank 1
answered on 23 Aug 2019, 04:34 PM
Thank you So much. 
Asked by
Mina
Top achievements
Rank 1
Answers by
Mina
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or