Problem in Searched data GridMvc

May 12, 2016 at 10:36 AM
Action1: public ActionResult _Lot(int? page, int? pagesize, FormCollection form) //Main Grid & Paging/Sorting
{
if (Request.IsAjaxRequest())
            {
                var grid = (AjaxGrid<VehicleDTO>)new AjaxGridFactory().CreateAjaxGrid(objLotList.AsQueryable(), page.HasValue ? page.Value : 1, page.HasValue, 10);
                return Json(new { Html = grid.ToJson("_LotGrid", this), grid.HasItems }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                var grid = (AjaxGrid<VehicleDTO>)new AjaxGridFactory().CreateAjaxGrid(objLotList.AsQueryable(), 1, false, 10);
                return View(grid);
            }

}

Action2: public ActionResult _SearchLot(int? page, int? pagesize) //Search data in Grid
{
var grid = (AjaxGrid<VehicleDTO>)new AjaxGridFactory().CreateAjaxGrid(objSearchLotVehicleDTO.AsQueryable(), page.HasValue ? page.Value : 1, page.HasValue, 10);
        return Json(new { Html = grid.ToJson("_LotGrid", this), grid.HasItems }, JsonRequestBehavior.AllowGet);

}

Main View.cshtml:

var ActionUrl = '/Auction/_Lot';
    var dataToBeSent = $('form').serialize();
    $.post(ActionUrl, dataToBeSent, function (data) {
        if (data) {                
            var AjaxUrl = '/Auction/_SearchLot';
                pageGrids.theLotGrid.ajaxify({
                    getPagedData: AjaxUrl,
                    getData: AjaxUrl
                });                   
                pageGrids.theLotGrid.refreshFullGrid();    //Refresh the entire Grid. Problem is here <-------------                            
        }

});

Note: After getting search result in partialview--->Again sorting or paging in that searched data grid--->gridmvc-ext.js file loading again & Search Action 2 or 4 times calling.

Pls give me solution: Normal grid (without search) ----> sorting/paging only one time calling.(working fine)