Jquery 如何在ajax调用中通过json结果绑定Syncfusion网格
我有一个下拉列表,在更改该下拉列表时,执行下面的ajax调用,我想从中绑定syncfusion网格。JSON方法正在命中并获取列表,但我无法将数据绑定到网格Jquery 如何在ajax调用中通过json结果绑定Syncfusion网格,jquery,data-binding,syncfusion,Jquery,Data Binding,Syncfusion,我有一个下拉列表,在更改该下拉列表时,执行下面的ajax调用,我想从中绑定syncfusion网格。JSON方法正在命中并获取列表,但我无法将数据绑定到网格 $.post( "User/GetUserData/", { 'CategoryId': CategoryId }, function (data) { // I want to bind the grid here }); 我尝试了两种方法,一种是返
$.post(
"User/GetUserData/",
{ 'CategoryId': CategoryId },
function (data) {
// I want to bind the grid here
});
我尝试了两种方法,一种是返回json结果,另一种是返回视图
备选案文1:
public JsonResult GetUserData(string CategoryId)
{
return Json(model.lstUserModel, JsonRequestBehavior.AllowGet);
}
备选案文2:
[HttpPost]
public ActionResult GetUserData(string CategoryId)
{
model.lstUserModel= GetUserData(Convert.Int32(CategoryId));
return View("UserView", model);
}
在这两个选项中,我都无法将数据绑定到列表。在ajax调用中获得数据后,然后将数据绑定到网格,如下所示
[HTML]
<div id="Grid"/>
[Script]
$.post(
"User/GetUserData/",
{ 'CategoryId': CategoryId },
function (data) {
$("#Grid").ejGrid({
dataSource: data, // data must be array of json
});
});
[HTML]
[文字]
美元邮政(
“User/GetUserData/”,
{'CategoryId':CategoryId},
功能(数据){
$(“#网格”).ejGrid({
dataSource:data,//数据必须是json的数组
});
});