<
li
>
<
label
class
=
"fieldName"
for
=
"CustomerName"
> Customer<
span
class
=
"red"
>*</
span
>:</
label
>
<
span
class
=
"fieldValue"
>
@(Html.Kendo().DropDownList()
.OptionLabel("Select ")
.Name("Customer")
.DataTextField("CustomerName")
.DataValueField("CustomerId")
.Value("CustomerId")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetCustomer", "AddFacility");
});
})
.Events(e => e.Change("dropdownlist_Validation"))
)
@Html.HiddenFor(m=>m.CustomerName)
<
div
id
=
"divcustomer"
>
@Html.Label("Required", new { @class = "red" });
</
div
>
<
script
type
=
"text/javascript"
>
function GetId() {
return {
Customer: $("#Customer").val()
};
}
</
script
>
@* @Html.ValidationMessageFor(model => model.CustomerName)*@
</
span
>
</
li
>
<
li
>
<
label
class
=
"fieldName"
for
=
"RegionName"
>Region<
span
class
=
"red"
></
span
>:</
label
>
<
span
class
=
"fieldValue"
>
@(Html.Kendo().DropDownList()
.OptionLabel("Select ")
.Name("Region")
.DataTextField("RegionName")
.DataValueField("RegionId")
//.Value("RegionId")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetRegion", "AddFacility")
.Data("filterRegion");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.CascadeFrom("Customer")
.Events(e => e.Change("dropdownlist_Validation"))
)
<
script
type
=
"text/javascript"
>
function filterRegion() {
return {
Customer: $("#Customer").val()
};
}
</
script
>
<
script
type
=
"text/javascript"
>
function GetId() {
return {
Region: $("#Region").val()
};
}
</
script
>
</
span
>
</
li
>
<
li
>
<
label
class
=
"fieldName"
for
=
"FacilityGroupName"
>Facility Group<
span
class
=
"red"
>*</
span
>:</
label
>
<
span
class
=
"fieldValue"
>
@(Html.Kendo().DropDownList()
.OptionLabel("Select ")
.Name("FacilityGroup")
.DataTextField("FacilityGroupName")
.DataValueField("FacilityGroupId")
.Value("FacilityGroupId")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetFacilityGroupName", "AddFacility")
//.Data("filterfacilitygroup")
.Data("filterfacilitygroup2");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.CascadeFrom("Region")
.CascadeFrom("Customer")
.Events(e => e.Change("dropdownlist_Validation"))
)<
div
id
=
"divfacilitygroupname"
>
@Html.Label("Required", new { @class = "red" });
</
div
>
@*<
script
type
=
"text/javascript"
>
function filterfacilitygroup() {
return {
Region: $("#Region").val()
};
}
</
script
>*@
<
script
type
=
"text/javascript"
>
function filterfacilitygroup2() {
return {
Customer: $("#Customer").val(),
Region: $("#Region").val()
};
}
</
script
>
<
script
type
=
"text/javascript"
>
function GetId() {
return {
FacilityGroup: $("#FacilityGroup").val()
};
}
</
script
>
</
span
>
</
li
>
public JsonResult GetCustomer()
{
var objCustomerName = CustomerNameTypeClient.GetCustomers().Select(CustomerT => new RegionModel
{
CustomerId = CustomerT.CustomerId,
CustomerName = CustomerT.CustomerName
});
return Json(objCustomerName, JsonRequestBehavior.AllowGet);
}
/// <
summary
>
/// Gets the region.
/// </
summary
>
/// <
returns
>Json</
returns
>
public JsonResult GetRegion(string Customer)
{
var VarRegionName = FacilityClient.GetRegion(Customer);
return Json(VarRegionName, JsonRequestBehavior.AllowGet);
}
/// <
summary
>
/// Gets the name of the facility.
/// </
summary
>
/// <
returns
>Json</
returns
>
public JsonResult GetFacilityGroupName(string Region, string Customer)
{
var VarFacilityGroupName = FacilityClient.GetFacilityGroup(Region, Customer);
return Json(VarFacilityGroupName, JsonRequestBehavior.AllowGet);
}
@(Html.Kendo().DropDownList()
.Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
.DataValueField("TaxImpsnId")
.DataTextField("TaxImpsnName")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("_AjaxMethod", "MyController", new { lookupId= 1 });
}).ServerFiltering(true);
})
)
::Edited :: Solved by changing Inherits="System.Web.Mvc.ViewPage<MVC3TelerikDemo.Models.Department>"
To
Inherits="System.Web.Mvc.ViewPage<IEnumerable<MVC3TelerikDemo.Models.Department>>"
Hi,
I am new with Telerik and trying to bind Linq.Table to the Kendo Dropdown. Following is the code.
-------Action Method---------
public ActionResult DropDownList()
{
DepartmentsDataContext context = new DepartmentsDataContext();
return View(context.Departments);
}
--------View Page--------
<%: Html.Kendo().DropDownList()
.Name("ddlDept")
.DataTextField("Name")
.DataValueField("DepartmentID")
.BindTo(Model)
.SelectedIndex(0)
%>
I get the following error: CS1502: The best overloaded method match for 'Kendo.Mvc.UI.Fluent.DropDownListBuilder.BindTo(System.Collections.Generic.IEnumerable<Kendo.Mvc.UI.DropDownListItem>)' has some invalid arguments
Thank you.
Yeou
Code:
$("#DropDownList1").change(function () {
custCode = $("#DropDownList1").val();
$("#titles").data("kendoDropDownList").dataSource.read(); //shows list Loading But Same Data Is present .
$("#titles").data("kendoDropDownList").refresh(); //NOT Working
});I am Tring to refresh my DropDownList after another DropDownList ..
is clicked but the refresh Method is not define error pops.
therefor i use the dataSource.read() then the DropDownList Shows it loading but data remain the same
@(Html.Kendo().DropDownListFor(m => m)
.DataSource(
datasource => datasource
.Read(r => r.Action("GetPossibleLines", "ProductionProgram"))
.ServerFiltering(true)
)
.DataTextField("Text")
.DataValueField("Value")
.HtmlAttributes(new { style = "width: 200px" }))
[HttpPost]
public
ActionResult GetPossibleLines()
{
var options =
new
List<SelectListItem>()
{
new
SelectListItem() { Text =
"LI50"
, Value =
"51"
}
};
return
Json(options);
}