Reputation: 407
I am working on Mvc.Grid (Grid.MVC5) and using its ajax-grid.
To call ajax-grid we have to call partial view from view as given below:-
@Html.AjaxGrid(Url.Action("AjaxGrid", new { tableName = "", type = ""}))
Can we call it using jQuery, I have tried below but didn't work, TIA.
$.ajax({
type: "POST",
data: { tableName: TableName_, type: SelectedType },
url: @Html.AjaxGrid(Url.Action("AjaxGrid"))
});
Partial view:-
public ActionResult AjaxGrid()
{
return PartialView("_KitchensData", FilterData());
}
public IEnumerable<KitchenModel> FilterData()
{
ViewBag.TableName = "SK_Kitchen";
KitchenModel model = new KitchenModel();
KitchenModel result = kitchenAccess.KitchenSearch(model);
IEnumerable<KitchenModel> _Kitchens = new List<KitchenModel>();
if (result != null)
{
if (result._Kitchens.Count > 0)
{
_Kitchens = result._Kitchens;
return _Kitchens;
}
}
return _Kitchens;
}
Upvotes: 0
Views: 2980
Reputation: 3502
can you try Jquery load method to parse your partial view in jquery.
//html
<div id="targetDiv"> </div>
// js
$("#targetDiv").load('@Url.Action("AjaxGrid", new { tableName = "", type = ""})')
Upvotes: 2