É totalmente compatível quando os dados estão sendo exportados.
$render=explode(" ",$_POST["partial_render"]);
if($_POST["source"]=="tbl"){
$_SESSION["inicio"]=$_POST["tbl_first"];
$_SESSION["paginas"]=$paginas=$_POST["tbl_rows"];
}
if(isset($_SESSION["inicio"])){
//valor normal
}else{
$_SESSION["inicio"]="0";
}
if(isset($_SESSION["paginas"])){
//valor normal
}else{
$_SESSION["paginas"]="10";
}
if($_POST["tbl_sortKey"]){
$_SESSION["order"]=$_POST["tbl_sortKey"];
}
if(isset($_SESSION["order"])){
//valor normal
}else{
$_SESSION["order"]="nome";
}
if(isset($_POST["tbl_sortDir"])){
if( $_POST["tbl_sortDir"]=="1"){
$_SESSION["dir"] = "ASC";
}
if( $_POST["tbl_sortDir"]=="-1"){
$_SESSION["dir"] = "DESC";
}
}
if(isset($_SESSION["dir"])){
//valor normal
}else{
$_SESSION["dir"]="ASC";
}
if($render[0]=="atual" or $render[0]=="tbl"){
$atual = " ORDER BY ".$_SESSION["order"]." ".$_SESSION["dir"]." LIMIT ".$_SESSION["inicio"]."," .$_SESSION["paginas"];
}else{
$atual = "";
}
$result = "SELECT * FROM clientes c INNER JOIN paises p ON c.pais=p.id_pais INNER JOIN representante r ON c.representante=r.id_representante INNER JOIN companhias o ON c.companhia=o.id_companhia WHERE nome LIKE "".$_POST["tbl:nome:filter"]."%" AND p.pais LIKE "".$_POST["pais:filter"]."%" AND o.companhia LIKE "".$_POST["companhia:filter"]."%" AND r.representante LIKE "".$_POST["representante:filter"]."%"";
$total = $pdo->query($result);
$extension ="{"totalRecords":".$total->rowCount()."}";
$result = $result.$atual;
$result = $pdo->query($result);
if($_POST["source"]=="tbl"){
$resposta="";
while ($linha = $result->fetch(PDO::FETCH_ASSOC)){
$resposta.="
<tr data-ri="".$linha["id_cliente"]."" class="ui-widget-content ui-datatable-even" role="row">
<td role="gridcell" class="">".$linha["nome"]."</td>
<td role="gridcell" class=""><span style="vertical-align: middle; margin-left: .5rem">".$linha["pais"]."</span></td>
<td role="gridcell" class="">".$linha["companhia"]."</td>
<td role="gridcell" class=""><img src="/sistema/resource/images/avatar/".$linha["foto_representante"].".png" alt="" width="32" style="vertical-align: middle" /><span style="vertical-align: middle; margin-left: .5rem">".$linha["representante"]."</span></td>
</tr>";
}
}
if($_POST["source"]=="xls"){
$render[0]="vazio";
$resposta="vazio";
$tasks = array();
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
$tasks[]=$row;
}
$conteudo="";
$heading = false;
if(!empty($tasks))
foreach($tasks as $row) {
if(!$heading) {
$conteudo.= implode("\t", array_keys($row)) . "\n";
$heading = true;
}
$conteudo.= implode("\t", array_values($row)) . "\n";
}
$eval="DinarteCoelho.download(\"data:application/vnd.ms-excel;base64,".base64_encode($conteudo)."\", \"application/vnd.ms-excel\", \"clientes.xls\", \"dinartecoelho.download_ui_data_dataexporter_lazy.php\")";
}
if($_POST["source"]=="xlsx"){
$render[0]="vazio";
$resposta="vazio";
$tasks = array();
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
$tasks[]=$row;
}
$conteudo="";
$heading = false;
if(!empty($tasks))
foreach($tasks as $row) {
if(!$heading) {
$conteudo.= implode("\t", array_keys($row)) . "\n";
$heading = true;
}
$conteudo.= implode("\t", array_values($row)) . "\n";
}
$eval="DinarteCoelho.download(\"data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,".base64_encode($conteudo)."\", \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\", \"clientes.xlsx\", \"dinartecoelho.download_ui_data_dataexporter_lazy.php\")";
}
if($_POST["source"]=="pdf"){
$render[0]="vazio";
$resposta="vazio";
include_once "../../../pdf-php-master/src/Cezpdf.php";
$pdf = new CezPDF("a4");
$pdf->selectFont("Helvetica");
$data = array();
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
$data[]=$row;
}
$pdf->ezText("\n<b>Tabela de Produtos</b>", 12);
$pdf->ezText("<b>Dados da consulta</b>", 10);
$pdf->ezTable($data, $cols, "", ["showHeadings" => 1, "shaded" => 1, "gridlines" => 31, "cols" => 1, "innerLineThickness" => 1, "outerLineThickness" => 1]);
$eval="DinarteCoelho.download(\"data:application/pdf;base64,".base64_encode($pdf->output())."\", \"application/pdf\", \"clientes.pdf\", \"dinartecoelho.download_ui_data_dataexporter_lazy.php\")";
}
if($_POST["source"]=="csv"){
$render[0]="vazio";
$resposta="vazio";
$tasks = array();
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
$tasks[]=$row;
}
$conteudo="";
$heading = false;
if(!empty($tasks))
foreach($tasks as $row) {
if(!$heading) {
$conteudo.= implode("\t", array_keys($row)) . "\n";
$heading = true;
}
$conteudo.= implode("\t", array_values($row)) . "\n";
}
$conteudo = str_replace(" ",";",$conteudo);
$eval="DinarteCoelho.download(\"data:text/csv; charset=UTF-8;base64,".base64_encode($conteudo)."\", \"text/csv; charset=UTF-8\", \"clientes.csv\", \"dinartecoelho.download_ui_data_dataexporter_lazy.php\")";
}
if($_POST["source"]=="xml"){
$render[0]="vazio";
$resposta="vazio";
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
$clientesArray[]=$row;
}
$doc = new DOMDocument("1.0");
$doc->formatOutput = true;
$root = $doc->createElement("cliente");
$root = $doc->appendChild($root);
for($i=0; $i<count($clientesArray); $i++){
$clienteId = $clientesArray[$i]["id_cliente"];
$clienteName = $clientesArray[$i]["nome"];
$clientePais = $clientesArray[$i]["pais"];
$clienteCompanhia = $clientesArray[$i]["companhia"];
$clienteRepresentante = $clientesArray[$i]["representante"];
$cliente = $doc->createElement("cliente");
$cliente->setAttribute("id", $clienteId);
$cliente = $root->appendChild($cliente);
$name = $doc->createElement("nome", $clienteName);
$cliente->appendChild($name);
$pais = $doc->createElement("pais", $clientePais);
$cliente->appendChild($pais);
$companhia = $doc->createElement("companhia", $clienteCompanhia);
$cliente->appendChild($companhia);
$representante = $doc->createElement("representante", $clienteRepresentante);
$cliente->appendChild($representante);
}
$eval="DinarteCoelho.download(\"data:text/xml; charset=UTF-8;base64,".base64_encode($doc->saveXML())."\", \"text/xml; charset=UTF-8\", \"clientes.xml\", \"dinartecoelho.download_ui_data_dataexporter_lazy.php\")";
}
if($_POST["source"]=="txt"){
$render[0]="vazio";
$resposta="vazio";
$tasks = array();
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
$tasks[]=$row;
}
$conteudo="";
$heading = false;
if(!empty($tasks))
foreach($tasks as $row) {
if(!$heading) {
$conteudo.= implode("\t", array_keys($row)) . "\n";
$heading = true;
}
$conteudo.= implode("\t", array_values($row)) . "\n";
}
$conteudo = str_replace(" ","|",$conteudo);
$eval="DinarteCoelho.download(\"data:text/plain; charset=UTF-8;base64,".base64_encode($conteudo)."\", \"text/plain; charset=UTF-8\", \"clientes.txt\", \"dinartecoelho.download_ui_data_dataexporter_lazy.php\")";
}
dc.cw("CommandButton", "widget_BtnXLS", {
id: "BtnXLS"
});
dc.cw("CommandButton", "widget_BtnXLSX", {
id: "BtnXLSX"
});
dc.cw("CommandButton", "widget_BtnPDF", {
id: "BtnPDF"
});
dc.cw("CommandButton", "widget_BtnCSV", {
id: "BtnCSV"
});
dc.cw("CommandButton", "widget_BtnXML", {
id: "BtnXML"
});
dc.cw("CommandButton", "widget_BtnTXT", {
id: "BtnTXT"
});
dc.cw("CommandButton", "widget_BtnPagXLS", {
id: "BtnPagXLS"
});
dc.cw("CommandButton", "widget_BtnPagXLSX", {
id: "BtnPagXLSX"
});
dc.cw("CommandButton", "widget_BtnPagPDF", {
id: "BtnPagPDF"
});
dc.cw("CommandButton", "widget_BtnPagCSV", {
id: "BtnPagCSV"
});
dc.cw("CommandButton", "widget_BtnPagXML", {
id: "BtnPagXML"
});
dc.cw("CommandButton", "widget_BtnPagTXT", {
id: "BtnPagTXT"
});
dc.cw("DataTable", "widget_formulario_tbl", {
id: "tbl"
, paginator: {
id: ['paginacao_topo', 'paginacao_base']
, rows: 10
, rowCount: 10
, page: 0
, currentPageTemplate: '({currentPage} of {totalPages})'
}
, filter: true
, sorting: true
, groupColumnIndexes: []
, disableContextMenuIfEmpty: false
});