i have an asp.net-mvc web page and i am using jqgrid on the front end. i want to have an export to excel button that will export the current set of data (based on the curr
What I have done is put the gridstate into the cache each time data is requested, then I do the export to excel using the gridState. There are examples of this somewhere on the jqGrid site:
//this fragment in GetData method
Session["ExceptionGridState"] = gridModel.ExceptionGrid.GetState(true);
Then when the export is called:
public ActionResult ExportToExcel_CurrentData()
{
var gridModel = new ExceptionJqGridModel();
var grid = gridModel.ExceptionGrid;
// call the ExportToExcel built-in method
JQGridState gridState = Session["ExceptionGridState"] as JQGridState;
gridState.CurrentPageOnly = false;
grid.ExportToExcel(SourceQuery(),
String.Format("SomeDatasetName_Filtered_{0:yyyymmddhhmm}.xls",
DateTime.Now),
gridState);
return View();
}
This works for me.