I have copy/paste detailModal from TDefaultDetailModal and added export function to it.
Here it is:
<?php
namespace Util;
use \koolreport\dashboard\widgets\Table;
use \koolreport\dashboard\containers\Modal;
use \koolreport\dashboard\inputs\Button;
use \koolreport\dashboard\inputs\Dropdown;
use \koolreport\dashboard\Lang;
use \koolreport\dashboard\Client;
trait detailModalExport
{
protected function detailModal($params = [])
{
$modal = Modal::create();
$dataView = $this->dataView();
return $modal
->title(Lang::t("Details"))
->type("info")
->size("lg")
->sub([
Table::create($this->name() . "DetailTable")
->pdfExportable(true)
->csvExportable(true)
->xlsxExportable(true)
->pageSize(10)
->dataSource($dataView->data())
->fields(function () use ($dataView) {
return array_map(
function ($field) {
return $field->clone();
},
$dataView->fields()
);
})
])
->footer([
Dropdown::create($this->name() . "DetailTableExport")
->title(Lang::t("Export"))
->type("primary")
->items([
Dropdown::menuItem()
->text("CSV")
->icon("fa fa-file-csv")
->onClick(
Client::showLoader().
Client::widget($this->name() . "DetailTable")->exportToCSV()
),
Dropdown::menuItem()
->text("PDF")
->icon("fa fa-file-pdf")
->onClick(
Client::showLoader().
Client::widget($this->name() . "DetailTable")->exportToPDF()
),
Dropdown::menuItem()
->text("XLS")
->icon("fa fa-file-excel")
->onClick(
Client::showLoader().
Client::widget($this->name() . "DetailTable")->exportToXLSX()
),
]),
Button::create()
->text(Lang::t("OK"))
->type("success")
->onClick(Modal::hide($modal))
]);
}
}
Now I can't find out how to add onExporting to $this->pageSize(null) in this trait.
There is a way to directly do that here or do I need to extend the Table class just to add the onExporting function to it?