KendoUI DropDownList,使用JavaScript用数据结果填充文本框



提前感谢。。。

我是KendoUI控件的新手,试图解决在更改Kendo DropDownList控件中的项目时更新文本框字段的问题。

我在加载View时使用ViewData方法填充DropDownList,然后调用Json结果方法,该方法返回该特定行,然后用于填充文本框字段。

我可以点击Json事件,但由于某种原因,我在jquery.min.js(jquery v1.9.1)文件中遇到了一个错误,函数(data)从未启动,它只是完全跳过它。

这是我从jquery.min.js文件中得到的错误。。。

GET http://localhost:52078/Settings/GetEtilizeLocale/7 500 (Internal Server Error)       jquery.min.js:19
b.ajaxTransport.send jquery.min.js:19
b.extend.ajax jquery.min.js:19
b.each.b.(anonymous function) jquery.min.js:19
ddlChange ViewLocales:192
i.extend.trigger kendo.all.min.js:9
o.extend._change kendo.all.min.js:14
o.extend._blur kendo.all.min.js:14
o.extend._focus kendo.all.min.js:14
o.extend._accept kendo.all.min.js:15
o.extend._click kendo.all.min.js:14
b.extend.proxy.b.isFunction.i jquery.min.js:4
b.event.dispatch jquery.min.js:4
b.event.add.v.handle

这是我的密码。。。

JS视图

    //Auto populate other edit popup fields when ddl changes value
    function ddlChange(e) {            
        $.get("/Settings/GetEtilizeLocale/" + $("#EtilizeLocaleID").data().kendoDropDownList.value(), function (data)
        {
            alert($('#Name').value());
            //$('#Name').val(data.name);
            //$('#LanguageCode').val(data.languagecode);
            //$('#CountryCode').val(data.countrycode);
            //$('#IsActive').val(data.isactive);
        });            
    }

C#控制器

public ActionResult GetEtilizeLocale(int id = 0)
    {
        var dataContext = new EtilizeEntities();
        Etilize_Locale loc = dataContext.Etilize_Locale.Find(id);
        return Json(loc);
    }

终于想通了!

必须更改

return Json(loc)

return Json(loc, JsonRequestBehavior.AllowGet);

对于任何遇到过这个问题的人。

最新更新