本文介绍了在选择公司后,如何将多选剑道下拉列表与部门的值绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我试图将部门多选剑道ui与公司选中。这就是我所做的。 这是我的公司下拉列表,填充了来自db的菜单Hi Guys,I was trying to bind department multiselect kendo ui with company selected. Here is what I have done.this is my company dropdown populated with menus from db<ul class="dropdown-menu" id="company-dropdown-menu"></ul>$.ajax({ url: "GetAllCompanies", type: "Get", async: true, success: function (data) { $("#company-dropdown-menu").append(data); } });public JsonResult GetAllCompanies() { var companies = cmnObj.GetAllCompany(); string dynamicCompanyList = ""; foreach (var company in companies) { dynamicCompanyList += "<li><a id=" + company.CompanyID + ">" + company.CompanyDesc + "</a><li>"; } return Json(dynamicCompanyList, JsonRequestBehavior.AllowGet); } 现在我选择公司并尝试绑定kendo multiselect中的部门后,我无法绑定它。Now after I select company and try to bind departments in kendo multiselect, I can't bind to it.$("#company-dropdown-menu").on("click", "li a", function () { var companyID = $(this).attr('id'); //assigning the value of selected company to the chosen company span tag $("#btnChosenCompany").text($(this).text()); var ddl = $('#Department_dropdown').data("kendoMultiSelect"); $.ajax({ url: "GetDepartment", type: "Get", async: true, data: { CompanyId: companyID }, success: function (listItems) { ddl.setDataSource(listItems); ddl.refresh(); } }); });public JsonResult GetDepartments(string CompanyId){ List<Department> AllDepartments = new List<Department>(); int CompanyID = int.Parse(CompanyId); if (CompanyID > 0) { AllDepartments = cmnObj.GetDepartmentsByCompany(CompanyID); } return Json(AllDepartments, JsonRequestBehavior.AllowGet);} kendo multiselect看起来像这样 @(Html.Kendo()。MultiSelectFor(id => id.DepartmentIdsFk) .Name(DepartmentIdsFk) .HtmlAttributes(new {@style =float:left; text-align:left; width:500px;,@ id =Department_dropdown}) .DataTextField(DepartmentName) .DataValueField(DepartmentID) .Placeholder(选择部门 ..) .AutoBind(true) .BindTo(Model.Departments.Select(id => new {id.DepartmentName,id.DepartmentID})) ) 有人可以帮我这个。 谢谢 我尝试过: @(Html.Kendo()。MultiSelectFor(id => id.DepartmentIdsFk) .Name(DepartmentIdsFk) .HtmlAttributes(new {@style =float:left; text-align:left; width:500px; ,@ id =Department_dropdown}) .DataTextField(DepartmentName) .DataValueField(DepartmentID) .Placeholder (选择部门..) .AutoBind(true) .BindTo(Model.Departments.Select(id => new {id.DepartmentName,id。 DepartmentID})) )the kendo multiselect looks like this @(Html.Kendo().MultiSelectFor(id => id.DepartmentIdsFk) .Name("DepartmentIdsFk") .HtmlAttributes(new { @style = " float: left; text-align: left; width:500px;", @id = "Department_dropdown" }) .DataTextField("DepartmentName") .DataValueField("DepartmentID") .Placeholder("Select Department..") .AutoBind(true) .BindTo(Model.Departments.Select(id => new { id.DepartmentName, id.DepartmentID })) )can someone help me with this.thanksWhat I have tried:@(Html.Kendo().MultiSelectFor(id => id.DepartmentIdsFk) .Name("DepartmentIdsFk") .HtmlAttributes(new { @style = " float: left; text-align: left; width:500px;", @id = "Department_dropdown" }) .DataTextField("DepartmentName") .DataValueField("DepartmentID") .Placeholder("Select Department..") .AutoBind(true) .BindTo(Model.Departments.Select(id => new { id.DepartmentName, id.DepartmentID })) )推荐答案 .ajax({ url: GetAllCompanies,类型: 获取,异步: true ,成功s: function (data){.ajax({ url: "GetAllCompanies", type: "Get", async: true, success: function (data) {( #公司下拉菜单)追加(数据)。 } });("#company-dropdown-menu").append(data); } });public JsonResult GetAllCompanies() { var companies = cmnObj.GetAllCompany(); string dynamicCompanyList = ""; foreach (var company in companies) { dynamicCompanyList += "<li><a id=" + company.CompanyID + ">" + company.CompanyDesc + "</a><li>"; } return Json(dynamicCompanyList, JsonRequestBehavior.AllowGet); } 现在我选择公司并尝试绑定kendo multiselect中的部门后,我无法绑定它。Now after I select company and try to bind departments in kendo multiselect, I can't bind to it.( #company-dropdown-menu)。on( click, li a, function (){ var companyID =("#company-dropdown-menu").on("click", "li a", function () { var companyID = 这篇关于在选择公司后,如何将多选剑道下拉列表与部门的值绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-12 03:45