Here is how we have handled it:
The grid is in its own page which is included on the main page.
list_grid.php
$ds = new MYSQLDataSource($db_con);
$sqlSelect="***snipped***";
$ds->SelectCommand = $sqlSelect;
$grid = new KoolGrid("grid");
$grid->scriptFolder = $KoolControlsFolder."/KoolGrid";
$grid->styleFolder = "climastyle";
$grid->AjaxEnabled = true;
$grid->AjaxLoadingImage = $KoolControlsFolder."/KoolAjax/loading/5.gif";
$grid->AllowHovering = true;
$grid->RowAlternative = true;
$grid->ColumnWrap = true;
$grid->AllowScrolling = true;
$grid->AllowFiltering = false;
$grid->Width = "1000px";
$grid->MasterTable->ColumnWidth ="100px";
$grid->MasterTable->DataSource = $ds;
$grid->MasterTable->AutoGenerateColumns = true;
$grid->Process();
A button is added to main page for "export to excel" with jquery function
$("#loadTable").button().click(function showGrid()
{
//alert(document.getElementById("startDatePicker").value);
mypanel.attachData("start",$('#startDatePicker').val());
mypanel.attachData("end",$('#endDatePicker').val());
grid.commit();
grid.refresh();
mypanel.update();
});
$("#exportTable").button().click(function (e){
tableExport();
});
function tableExport(){
var cURL=window.location.protocol + "//" + window.location.host + "csAjaxUtils.php";
var csURL = cURL + "?parms="+$('#val').val(); //Things to keep grid with same options, in our case, SQL manipulation
window.location=csURL;
}
Then the csAjaxUtils
<?php
include_once "../../appConfig.php";
$KoolControlsFolder = "../../libs/KoolPHPSuite/KoolControls";
require $KoolControlsFolder."/KoolGrid/koolgrid.php";
include "list_grid.php";
$grid->ExportSettings->IgnorePaging=true;
$grid->ExportSettings->FileName="FOO";
$grid->GetInstanceMasterTable()->ExportToExcel();
?>