I have converted the kendo dropdownlist into kendo multiselect.
Dropdownlist contains 2 items:
- D-UDMS-TMA Data Mgmt System
- U-TDMS-SMA Mgmt System
$("#btnSendFlow").click(function () {
debugger;
var FlowData_array = [];
//var ROLECODE = $("#DDRolecode").val().trim();---For dropdownlist output: "D"
var ROLECODE = $("#DDRolecode").data("kendoMultiSelect").value();//added by chetan for multiselect output: "D" "U"
// var MPID = $("#DDRolecode").data("kendoDropDownList").text().split('-');---for dropdownlist output: (3)["D","UDMS","TMA Data Mgmt System"]
var MPID = $("#DDRolecode").data("kendoMultiSelect").value().split('-');//added for multiselect(How to do For multiple selected items?)-->
output should be like:
(3)["D","UDMS","TMA Data Mgmt System"]
(3)["U","TDMS","SMA Mgmt System"]
.....
.....
}
Commented lines is for Dropdownlist.
Output should be like for var MPID:
(3)["D","UDMS","TMA Data Mgmt System"]
(3)["U","TDMS","SMA Mgmt System"]
I have converted the kendo dropdownlist into kendo multiselect.
Dropdownlist contains 2 items:
- D-UDMS-TMA Data Mgmt System
- U-TDMS-SMA Mgmt System
$("#btnSendFlow").click(function () {
debugger;
var FlowData_array = [];
//var ROLECODE = $("#DDRolecode").val().trim();---For dropdownlist output: "D"
var ROLECODE = $("#DDRolecode").data("kendoMultiSelect").value();//added by chetan for multiselect output: "D" "U"
// var MPID = $("#DDRolecode").data("kendoDropDownList").text().split('-');---for dropdownlist output: (3)["D","UDMS","TMA Data Mgmt System"]
var MPID = $("#DDRolecode").data("kendoMultiSelect").value().split('-');//added for multiselect(How to do For multiple selected items?)-->
output should be like:
(3)["D","UDMS","TMA Data Mgmt System"]
(3)["U","TDMS","SMA Mgmt System"]
.....
.....
}
Commented lines is for Dropdownlist.
Output should be like for var MPID:
(3)["D","UDMS","TMA Data Mgmt System"]
(3)["U","TDMS","SMA Mgmt System"]
Share
Improve this question
edited Sep 23, 2019 at 21:39
halfer
20.3k19 gold badges109 silver badges202 bronze badges
asked Sep 9, 2019 at 11:39
chetan kamblichetan kambli
8141 gold badge8 silver badges24 bronze badges
3 Answers
Reset to default 3You need to use the dataItems
method on the multiselect to get the underlying selected dataItems.
so all you should need to do is change your code from:
var MPID = $("#DDRolecode").data("kendoMultiSelect").value().split('-')
to:
var MPID = $("#DDRolecode").data("kendoMultiSelect").dataItems();
So this will give you an array of dataItems that you have selected. So if you need to only have the id then either change the value mapping
to valuePrimitive:true
or map the returning dataItems to the array list you need.
I have included a dojo showing how to get the items: https://dojo.telerik./ILEvITUQ
This is taken from the api demo dojo for multiselects but I have changed the Get Values
button to map the items to their values only and also stringifying the dataItems array.
You can do like:
var selectedValues = $("#DDRolecode").data("kendoMultiSelect").value().map(item => item.split("-"));
The result will be:
Demo
The Below code worked for me:
var control = $("#DDRolecode").data("kendoMultiSelect");
var selectedDataItems = control.dataItems();
//// create an array that only contains the selected ids
var MPID = [];
$(selectedDataItems).each(function () {
MPID.push(this.Name.split('-')); // you can access any property on your model here
});
console.log(MPID);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742342864a4425976.html
评论列表(0条)