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
You could put hidden fields inside the Export to Excel form:
@using (Html.BeginForm(new { action = "ExportToExcel" }))
{
@Html.Hidden("sidx")
@Html.Hidden("sord")
@Html.Hidden("page")
@Html.Hidden("rows")
}
and populate them upon form submission based on the current values:
$('form').submit(function () {
var grid = $('#list');
var sortname = grid.getGridParam('sortname');
var sortorder = grid.getGridParam('sortorder');
var page = grid.getGridParam('page');
var rows = grid.getGridParam('rowNum');
$('#sidx').val(sortname);
$('#sord').val(sortorder);
$('#page').val(page);
$('#rows').val(rows);
});
This way the ExportToExcel
controller action will take those parameters and be able to filter the list.