<script> //联动查询 $(function () { $("#BranchName").change(function () { var parent = $("#BranchName option:selected").val(); if (parent != "" && parent !=0 ) { $.ajax({ url: "/Store/GetStore?branchId=" + $("#BranchName option:selected").val(), type: "get", success: function (data) { if (data.Data.length > 0) { var op = ""; for (var i = 0; i < data.Data.length; i++) { op += "<option value=" + data.Data[i].Id + ">" + data.Data[i].DealerName + "</option>" } $("#DealerName").html(op); } if (data.Data == "") { var option = "<option></option>" $("#DealerName").html(option); } } }); } else { eqlee.showWarring("请选择分公司和经销商"); $("#DealerName").html("<option> 请选择</option>"); } }); }); </script>
上面是实现联动脚本
public JsonResult GetStore(Guid branchId) { var data = new Models.ReturnJson() { Error = false }; var filter = string.Format(" Deleted = 0 and branchId = ‘{0}‘",branchId); var dealerModel = _bllDealer.List(where: filter); var id = dealerModel.Select(x => x.Id); var dealerName = dealerModel.Select(x => x.DealerName); data = new Models.ReturnJson() { Error = false, Data = dealerModel }; return JsonNet(data, behavior: JsonRequestBehavior.AllowGet); }
上面是后台获取联动的方法
以上是获取联动的方法,因为没有时间细写,只能简便点。