Reputation: 4524
I have a dropdown list, On change of that dropdown, doing the below ajax call from which I want to bind the syncfusion grid. JSON method is hitting and getting the list but I am unable to bind the data to grid.
$.post(
"User/GetUserData/",
{ 'CategoryId': CategoryId },
function (data) {
// I want to bind the grid here
});
I tried in 2 ways one is to return json result an other way returning the view
Option 1:
public JsonResult GetUserData(string CategoryId)
{
return Json(model.lstUserModel, JsonRequestBehavior.AllowGet);
}
Option 2:
[HttpPost]
public ActionResult GetUserData(string CategoryId)
{
model.lstUserModel= GetUserData(Convert.Int32(CategoryId));
return View("UserView", model);
}
in both the option I am unable to bind the data to list.
Upvotes: 1
Views: 1963
Reputation: 2281
After you got data in ajax call then bind data to grid like below.
[HTML]
<div id="Grid"/>
[Script]
$.post(
"User/GetUserData/",
{ 'CategoryId': CategoryId },
function (data) {
$("#Grid").ejGrid({
dataSource: data, // data must be array of json
});
});
Upvotes: 2