Saturday, 17 October 2015

Example of kendo multiselect dropdown in MVC





SUBMIT


VIEW
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
@Html.DropDownListFor(model => model.SUSER, new SelectList(Model.USER, "Value", "Text"))
</div>




<script type="text/javascript">

$(function () {


var selectedusers = $("#SUSER").kendoMultiSelect().data("kendoMultiSelect");

$(".k-multiselect-wrap.k-floatwrap").addClass("multiselectionWrap");

$(".multiselectionWrap ul").addClass("multiselectionWrapList");

$('#btnc').click(function(){






$.ajax({
cache: false,

type: "POST",

url: '../Repackaging/RepackagingUpdate',






data:{lst:selectedusers.value},
success: function ()






{
                   






}


});


});
Controller:
public void RepackagingUpdate(List<int> lst)










{






}


UPDATION :
Controller :
public JsonResult FillDropDown(int RepackagingId)






{
var Lmetadata = _repackagingService.GetAllRepackagingUserMapping().ToList().Where(n => n.RepackaingId == RepackagingId).Select(m => m.UserId);

return Json(Lmetadata.ToArray(), JsonRequestBehavior.AllowGet);








}




VIEW


$.ajax({
cache: false,

type: "POST",

url: '../Repackaging/FillDropDown',






data:{RepackagingId:dataItem.RepackaingId},
success: function (data)






{
$("#SUSER").data("kendoMultiSelect").value('');

$("#SUSER").data("kendoMultiSelect").value(data);









}


});
fill also jquery

<select id="SUSER"></select>


<script type="text/javascript">

$(function () {

var m=@Html.Raw(Json.Encode(Model.USER));

$("#SUSER").kendoMultiSelect({

dataTextField: "Text",

dataValueField: "Value",



});



$("#SUSER").data("kendoMultiSelect").setDataSource(m);

$(".k-multiselect-wrap.k-floatwrap").addClass("multiselectionWrap");

$(".multiselectionWrap ul").addClass("multiselectionWrapList");



 

 

 

});

</script>



 

 






No comments:

Post a Comment