I assume you read an example of a cascading drop-down list on a Kendo site with a cshtml source.
The second drop-down list corresponds to products and cascades from categories as follows:
@(Html.Kendo().DropDownList() .Name("products") .OptionLabel("Select product...") .DataTextField("ProductName") .DataValueField("ProductID") .DataSource(source => { source.Read(read => { read.Action("GetCascadeProducts", "ComboBox") .Data("filterProducts") .Type(HttpVerbs.Post); // This line serves to accept POST requests }) .ServerFiltering(true); }) .Enable(false) .AutoBind(false) .CascadeFrom("categories")
(note that I had to add a line to accept the sending request)
In this example, you will need a controller with the following syntax:
[HttpPost] public JsonResult GetCascadeProducts(int category) { List<Product> Products = new List<Product>(); Products.Add(new Product(1, 0, "Chai")); Products.Add(new Product(1, 1, "Chang")); Products.Add(new Product(1, 2, "Guarana Fantastica")); Products.Add(new Product(2, 0, "Aniseed Syrup")); Products.Add(new Product(2, 1, "Seasoning")); var ProductsInCategory = from p in Products where p.CategoryID == category select p; return Json(ProductsInCategory); }
The template for my class is as follows:
public class Product { public int CategoryID { get; set; } public int ProductID { get; set; } public string ProductName { get; set; } public Product(int category, int id, string name) { CategoryID = category; ProductID = id; ProductName = name; } }
If you have the correct Javascript function:
function filterProducts() { return { category: $("#categories").val() }; }
(the category should be the same as the parameter name in the controller method) as a rule, everything should work fine!