admin管理员组文章数量:1333631
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);
本文标签: javascriptHow to take the selected text in Kendo multiselect variableStack Overflow
版权声明:本文标题:javascript - How to take the selected text in Kendo multiselect variable? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742342863a2456952.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论