javascript - How to take the selected text in Kendo multiselect variable? - Stack Overflow

I have converted the kendo dropdownlist into kendo multiselect.Dropdownlist contains 2 items:D-UDMS-TMA

I have converted the kendo dropdownlist into kendo multiselect.

Dropdownlist contains 2 items:

  1. D-UDMS-TMA Data Mgmt System
  2. 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:

  1. D-UDMS-TMA Data Mgmt System
  2. 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
Add a ment  | 

3 Answers 3

Reset to default 3

You 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信