I have one JqGrid which loads data from controller on Search button click. Code for button click event can be checked here.
public JsonResult GetAllMessages(string sidx, string sord, int page, int rows, string messageType = "")
{
int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
List<AllDBMessages> messages = _domain.GetMessages(messageType);
var ListResults = messages.ToList().Select(
a => new
{
a.SerialNo,
a.MessageType,
a.TotalMessages,
a.Description,
a.Version,
a.MessageControlID,
a.SendingApplication,
a.SendingFacility,
a.ReceivingApplication,
a.ReceivingFacility,
a.DateTimeOfMessage,
a.DateInserted
});
int totalRecords = ListResults.Count();
var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);
if (sord.ToUpper() == "DESC")
{
ListResults = ListResults.OrderByDescending(s => s.MessageType);
ListResults = ListResults.Skip(pageIndex * pageSize).Take(pageSize);
}
else
{
ListResults = ListResults.OrderBy(s => s.MessageType);
ListResults = ListResults.Skip(pageIndex * pageSize).Take(pageSize);
}
var jsonData = new
{
total = totalPages,
page,
records = totalRecords,
rows = ListResults
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
On first grid I have written onCellSelect event for Jqgrid which is fired for the first time but not second time. Controller code for fetching data for 2nd Grid is;
public JsonResult GetMessagesDetail(string messageType, string sidx, string sord, int page, int rows)
{
return GetAllMessages(sidx, sord, page, rows, messageType);
}
Why my data is not loading onCellSelect second time. I have seen in DevTools that event is fired everytime but Jqgrid is not refreshed and action method is not fired second time.
Thanks @Oleg. I have fixed this with the help of this piece of code. Hope this help others too.
$('#grid-table1').trigger("reloadGrid", [{ page: 1 }]);