or
columns.Bound(p => p.Employee).ClientTemplate("#=Employee.EmployeeText#").Width(110);//This column for foreign key
[UIHint("EmployeeForeignKeyEditor")]
public EmployeeViewModel Employee { get; set; }
@model SpinePOCViewModel.ViewModels.EmployeeViewModel
@(
Html.Kendo().ComboBox()
.DataTextField("EmployeeText")
.DataValueField("EmployeeID").Name("Employee")
.Placeholder("Select Employee")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("MarketingCoordinatorcb_Read", "Marketing");
})
.ServerFiltering(true);
})
.AutoBind(false)
)
public ActionResult MarketingCoordinatorcb_Read()
{
ViewBag.Employees=SomeFunctionToGetData();
return Json((List<
EmployeeViewModel
>)ViewBag.Employees, JsonRequestBehavior.AllowGet);
}
public partial class EmployeeViewModel
{
public int EmployeeID { get; set; }
public virtual string EmployeeText { get;set;}
}
<
div
class
=
"k-edit-field"
data-container-for
=
"TeamId"
>
<
input
data-role
=
"combobox"
data-bind
=
"value: TeamId"
/>
</
div
>
How can I do this in the MVC world? I think I can't have all done via Mvc without using javascript... or should I create a viewmodel that holds those collections?
If I use "pure" js I would have 3 calls to the service from js, store the values and perform as I've written above
Any suggestion?
Thanks
<
div
id
=
"myform"
>
@(Html.Kendo().DropDownList()
.Name("cbFiliali")
.HtmlAttributes(new { style = "width: 250px" })
.DataTextField("Descr")
.DataValueField("ID")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetListaFiliali", "Common", new { Area = string.Empty });
}).ServerFiltering(false);
})
)
<
input
id
=
"btnCarica"
type
=
"button"
value
=
"CARICA"
/>
</
div
>
<
script
>
var validator = $("#myform").kendoValidator(
{
rules: {
customRule1: function (input) {
// all of the input must have a value
return $.trim(input.val()) !== "";
}
}
}).data("kendoValidator");
//validate the state on button click
$("#btnCarica").click(function () {
//validate the input elements and check if there are any errors
//if (validator.validate()) {
if (validator.validateInput($("DropDownList[name=cbFiliali]"))) {
var ddFiliali = $("#cbFiliali").data("kendoDropDownList");
var filiale = ddFiliali.value();
alert(filiale);
}
else
alert("NON VALIDO");
});
</
script
>