Get KoolPHP UI with 30% OFF!

KoolGrid PDF/Excel/... export from inside UpdatePanel

Riho Ellermaa
In order to allow users to change the filtering of data via Ajax I have placed my KoolGrids inside UpdatePanel .
Everything works OK, but when I tried to implement Exporting then after calling
ob_end_clean();
$grid->GetInstanceMasterTable()->ExportToExcel();
I still see the HTML from outside of the UpdatePanel and then the Excel binary.
Is there any trick to handle the export from inside Ajax container?
Posted Jan 17, 2016 Kool
Derek
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();
?>
Posted Jun 22, 2016 Kool -