I have converted the kendo dropdownlist into kendo multiselect. I wanted to pass multiple selected values to the controller.
Dropdownlist contains:
- D-UDMS-TMA Data Mgmt System
- U-TDMS-SMA Mgmt System
The below is my code:
$("#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 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);
//
output for MPID while debugging:
(3)["D","UDMS","TMA Data Mgmt System"] which is 0: Array(3)
0: "D"
1: "UDMS"
2: "TMA Data Management Ltd"
length: 3
(3)["U","TDMS","SMA Mgmt System"] which is 1: Array(3)
0: "M"
1: "BMET"
2: "Bglobal NHH MOP"
length: 3
length:2
//
.....
.....
MstHeaderData = {
REG_ID: $("#hfRegid").val(),
DataFlow_ID: $("#DDDataFlow").val(),
RoleCode: ROLECODE,//How to to do for the multiselect values.
//RoleCode: ROLECODE.trim(),//for dropdownlist
// MPID: MPID[1] //for dropdownlist
MPID: MPID// How to do for the multiselect values
}
}
Commented lines is for Dropdownlist.
I am passing the mutiple(selected ie. Rolecode and MPID) values to the controller's Headerdetails.
The below is my Controller call:
public ActionResult SaveSendFlowDetails(Temp_Flow_Generation_Item[] SSFD,HeaderDetails HeaderDetails, FormCollection form)
{
....
.....
}
Class file:
public class HeaderDetails
{
public int REG_ID { get; set; }
public int DataFlow_ID { get; set; }
public string RoleCode { get; set; }
public string MPID { get; set; }
}