0
안녕하세요 저는 Kendo MVC Grid in cell
모드를 사용하고 있습니다. 계단식 드롭 다운 목록을 작성하려고합니다. SubCategory
드롭 다운 목록을 기준으로 드롭 다운 목록을 작성하려고합니다. 내가 대신 실제 값의 undefined
으로 JSON
에 의해 반환되는 결과를 얻을 것을 제외하고 잘 작동 모든 것을 가지고, 여기 ajax
일부 코드 여기
Json은 Kendo Dropdownlist에 "정의되지 않음"을 반환합니까?
@(Html.Kendo().Grid<WebApplication6.Models.SubSubCategory>()
.Name("grid")
.Events(events => events.Change("Grid_OnRowSelect"))
.Columns(columns =>
{
columns.ForeignKey(c => c.CategoryID, (System.Collections.IEnumerable)ViewData["Category"],"CategoryID","CategoryName").Title("Category");
columns.ForeignKey(c => c.SubCategoryID (System.Collections.IEnumerable)ViewData["SubCategory"], "SubCategoryID", "SubCategoryName").Title("Sub-Category");
입니다 : -
<script>
Grid_OnRowSelect = function (e) {
var CatID = (this.dataItem(this.select()).CategoryID);
$.ajax({
//url: "SubSubCategories/SearchSubCategory",
url:'@Url.Action("SearchSubCategory", "SubSubCategories")',
type: "GET",
data: { CategoryID: CatID },
dataType: "json",
success: function (retData) {
if (JSON.stringify(retData) != "[]") {
var ddl = $('#SubCategoryID').data("kendoDropDownList");
ddl.setDataSource(retData);
ddl.refresh();
}else {
alert("No");
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
}
});
<script>
ADV에서
public JsonResult SearchSubCategory(int CategoryID)
{
var x = ((db.SubCategories.Select(p =>
new { CategoryID = p.CategoryID, SubCategoryID = p.SubCatgeoryID, SubCategoryName = p.SubCategoryName }))
.Where(p => p.CategoryID == CategoryID));
return Json(x, JsonRequestBehavior.AllowGet);
}
감사합니다 - :
그리고 여기에는 간단한 컨트롤러 (SubSubCategories)입니다 ANCE :
문제는 컨트롤러에서 데이터를 검색하는JQuery
코드에 있었다