asp.net mvc - Kendo MVC Cascading Dropdownlist Issue -
i using kendo ui asp.net mvc
, want cascading drop-down list using it. having problem in 3rd drop-down list shows values database instead of selected id value second drop-down list.
my controller code :-
public actionresult cdropdown() { return view(); } public jsonresult getcascadedept() { return json(db.deptdata.select(c => new { departmentid = c.departmentid, departmentname = c.departmentname }), jsonrequestbehavior.allowget); } public jsonresult getcascadeemployee(int? departmets) { var empdata = db.empdata.asqueryable(); if (departmets != null) { empdata = empdata.where(p => p.departmentid == departmets); } return json(empdata.select(p => new { employeeid = p.employeeid, empname = p.empname }), jsonrequestbehavior.allowget); } public jsonresult getcascademovies(int? employees) { var d = c in db.empmovies orderby c.moviename select c; var moviedata = db.empmovies.asqueryable(); if (employees != null) { int cat = convert.toint32(employees); moviedata = moviedata.where(p => p.employeeid == employees); } return json(moviedata.select(p => new { movieid = p.movieid, moviename = p.moviename }), jsonrequestbehavior.allowget); }
my view code :-
<div> <p> <label for="departmets">department :- </label> @(html.kendo().dropdownlist() .name("departmets") .htmlattributes(new { style = "width:300px" }) .optionlabel("-- select department --") .datatextfield("departmentname") .datavaluefield("departmentid") .datasource(source => { source.read(read => { read.action("getcascadedept", "home"); //.data("filterdepartmets"); }) .serverfiltering(true); }) .selectedindex(0) ) </p> <p> <label for="employees">employee :- </label> @(html.kendo().dropdownlist() .name("employees") .htmlattributes(new { style = "width:300px" }) .optionlabel("-- select employee --") .datatextfield("empname") .datavaluefield("employeeid") .datasource(source => { source.read(read => { read.action("getcascadeemployee", "home") .data("filteremployees"); }) .serverfiltering(true); }) .enable(false) .autobind(false) .selectedindex(0) .cascadefrom("departmets") ) <script type="text/javascript"> function filteremployees() { return { departmets: $("#departmets").val() }; } </script> </p> <p> <label for="movies">movie names :- </label> @(html.kendo().dropdownlist() .name("movies") .htmlattributes(new { style = "width:300px" }) .optionlabel("-- select movie --") .datatextfield("moviename") .datavaluefield("movieid") .datasource(source => { source.read(read => { read.action("getcascademovies", "home") .data("filtermovies"); }) .serverfiltering(true); }) .enable(false) .autobind(false) .selectedindex(0) .cascadefrom("employees") ) <script type="text/javascript"> function filtermovies() { return { movies: $("#filtermovies").val() }; } </script> </p> </div>
i using kendo ui asp mvc dropdown list - 3rd dropdown shows values table - id not getting. don't know why happening. solution?
you have error in filtermovies
function. want filter movies selected employee function should follows (note different property name movies
-> employees
, , different $ selector "#filtermovies"
-> "#employees"
):
function filtermovies() { return { employees: $("#employees").val() }; }
hope helps.
Comments
Post a Comment