0

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;
        }
4
  • can you paste your AjaxGrid method here ? which returning you a partial view? Commented Jun 15, 2017 at 11:45
  • have updated my question, pl check.. Commented Jun 15, 2017 at 11:49
  • Replace @Html.AjaxGrid(Url.Action("AjaxGrid", new { tableName = "", type = ""})) with @Html.AjaxGrid(Url.Action("AjaxGrid")) as you are not passing any parameters to this method Commented Jun 15, 2017 at 11:56
  • @SunilChaudhary I searched a while and found a way with jquery load. I couldn't test it. Commented Jun 15, 2017 at 12:04

1 Answer 1

2

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 = ""})')
Sign up to request clarification or add additional context in comments.

3 Comments

it loaded ajax grid but grid not working like filters not there , paging is there but not working..
@SunilChaudhary also I found ajaxify method can you take a look at this link gridmvcajax.codeplex.com/documentation
Hi Sunil any solution. same here the filters and pagination is not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.