jquery ajax working version guide (mvc 5)

Nov 7, 2014 at 7:10 PM
partialPage:
@model Grid.Mvc.Ajax.GridExtensions.AjaxGrid < Model >
@using GridMvc.Html
@using GridMvc.Sorting
@Html.Grid(Model, "_Grid").Named("gridName").Columns(columns =>
{
    columns.Add(c => c.ColumnName);
 }
View- Index page:

@Html.Partial("_partialPage", Model.GridData, new ViewDataDictionary { { "paramid", Model.Property} })
$(document).ready(function () {

    var self = this;
    this.currentPage = 1;

    this.pad = function (query) {
        if (query.length == 0) return "?page=";
        return query + "&page=";
    };

    $('.classSelectorOnRowelement').on('click', function (e) {
        var gridTableBody = $(this).closest(".grid-wrap").find("tbody");

        var url = '/Controller/Action/';
        var userid = $(this).data("userid");
        var id = $(this).data("id");
        $.ajax({
            url: url,
            dataType: 'json',
            type: 'POST',
            data: { userid: userid, id: id },
            success: function (response) {
                gridTableBody.html(response.Html);
            },
            error: function (xhr, textStatus, thrownError) {
                alert('error');
            }
        });
    });

});
Controller:
    // GET: User/Delete/5
    [HttpPost]
    public JsonResult ControllerName(int userId, int id)
    {
        object result;
        try
        {

            var vm = GridData.AsQueryable();
            var ajaxGridFactory = new Grid.Mvc.Ajax.GridExtensions.AjaxGridFactory();
            var grid = ajaxGridFactory.CreateAjaxGrid(vm, 1, true);

            return Json(new { Html = grid.ToJson("_partialPage", this), grid.HasItems, Success = "True" }, JsonRequestBehavior.AllowGet);
        }
        catch (Exception ex)
        {
            result = new { Success = "False", Message = ex.Message };
        }            

        return Json(result, JsonRequestBehavior.AllowGet);
    }
Please see the demo site on project source code on how to set up your model to integrate well with control.