The filename which KoolGrid export can be changed by using property FileName of ExportSettings.
$grid->ExportSettings->FileName="Report";
Note: The file extension will be added according to the exporting function that you called. For example, if you call ExportToPDF(), the extension ".pdf" will be attached to the filename.
<?php
require_once $KoolControlsFolder."/KoolGrid/library/tcpdf/config/lang/eng.php";
require_once $KoolControlsFolder."/KoolGrid/library/tcpdf/tcpdf.php";
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolGrid/koolgrid.php";
require $KoolControlsFolder."/KoolGrid/ext/datasources/MySQLiDataSource.php";
$ds = new MySQLiDataSource($db_con);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
$ds->SelectCommand = "select customerNumber,customerName,phone,city from customers";
$grid = new KoolGrid("grid");
$grid->scriptFolder = $KoolControlsFolder."/KoolGrid";
$grid->styleFolder="default";
$grid->DataSource = $ds;
$grid->Width = "655px";
//Enable Ajax Mode
$grid->AjaxEnabled = true;
//Add loading image
$grid->AjaxLoadingImage = $KoolControlsFolder."/KoolAjax/loading/5.gif";
$grid->RowAlternative = true;
$grid->AutoGenerateColumns = true;
$grid->MasterTable->Pager = new GridPrevNextAndNumericPager();
$grid->Process();
if(isset($_POST["FileName"]))
{
$grid->ExportSettings->FileName = $_POST["FileName"];
}
if(isset($_POST["ExportToPDF"]))
{
ob_end_clean();
$grid->GetInstanceMasterTable()->ExportToPDF();
}
?>
<form id="form1" method="post">
<?php echo $koolajax->Render();?>
<div style="margin-bottom:10px;padding:10px;width:635px;background:#DFF3FF;border:solid 1px #C6E1F2;">
Enter filename:
<br/>
<input type="textbox" id="FileName" name="FileName" value="<?php echo $grid->ExportSettings->FileName?>"/>
<br/><br/>
<input type="submit" name="ExportToPDF" value = "Export to PDF" />
</div>
<?php echo $grid->Render();?>
</form>