TableTools date range
TableTools date range
mf_a2if
Posts: 32Questions: 0Answers: 0
Hi all,
I use TableTools, with download function and it's work.
When I use filters, it's good but I don't know why, when I use a date range filter, in my export, I don't have this filter.
However, the filter is working in my datatable.
Can you help me ?
Code JS
[code]
TableTools.BUTTONS.download = {
"sAction": "text",
"sTag": "default",
"sFieldBoundary": "",
"sFieldSeperator": "\t",
"sNewLine": "
",
"sToolTip": "",
"sButtonClass": "DTTT_button_text",
"sButtonClassHover": "DTTT_button_text_hover",
"sButtonText": "Download",
"mColumns": "all",
"bHeader": true,
"bFooter": true,
"sDiv": "",
"fnMouseover": null,
"fnMouseout": null,
"fnClick": function( nButton, oConfig ) {
var oParams = this.s.dt.oApi._fnAjaxParameters( this.s.dt );
var iframe = document.createElement('iframe');
iframe.style.height = "500px";
iframe.style.width = "1000px";
iframe.src = oConfig.sUrl+"?"+$.param(oParams);
document.body.appendChild( iframe );
},
"fnSelect": null,
"fnComplete": null,
"fnInit": null
};
$(document).ready(function() {
// Affichage du tableau avec le détail des entrées
$('#tabDetail').dataTable({
"aaSorting": [[ 1, 'desc' ]],
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"aButtons": [{
"sExtends": "download",
"sButtonText": "EXCEL",
"sUrl": "extranet/scriptPHP/csvGeneral.php"
},{
"sExtends": "download",
"sButtonText": "PDF",
"sUrl": "extranet/scriptPHP/pdfGeneral.php"
}]
},
"sAjaxSource": "extranet/scriptPHP/serverSideGeneral.php",
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "json",
"cache": false
} );
}
}).columnFilter({
aoColumns: [{ type: "text" },
{ type: "date-range"},
{ type: "time-range" , values: ["07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]},
{ type: "select", values: ['muret', 'labarthe']}]
});
});
[/code]
csvGeneral.php code :
[code]
<?php
//envoi des headers csv
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="Detail des entrees.csv"');
// Champs de la base de données
$aColumns = array( 'usager', 'date', 'heure', 'decheterie', 'commune', 'etat');
// Table
$sTable = "te_stats";
// Connexion à la base
include("../inc/gestiondech_config.inc.php");
// Eventuels filtres
$sWhere = "";
if ( $_GET['sSearch'] != "" ){
$sWhere = "WHERE (";
for ( $i=0 ; $i
I use TableTools, with download function and it's work.
When I use filters, it's good but I don't know why, when I use a date range filter, in my export, I don't have this filter.
However, the filter is working in my datatable.
Can you help me ?
Code JS
[code]
TableTools.BUTTONS.download = {
"sAction": "text",
"sTag": "default",
"sFieldBoundary": "",
"sFieldSeperator": "\t",
"sNewLine": "
",
"sToolTip": "",
"sButtonClass": "DTTT_button_text",
"sButtonClassHover": "DTTT_button_text_hover",
"sButtonText": "Download",
"mColumns": "all",
"bHeader": true,
"bFooter": true,
"sDiv": "",
"fnMouseover": null,
"fnMouseout": null,
"fnClick": function( nButton, oConfig ) {
var oParams = this.s.dt.oApi._fnAjaxParameters( this.s.dt );
var iframe = document.createElement('iframe');
iframe.style.height = "500px";
iframe.style.width = "1000px";
iframe.src = oConfig.sUrl+"?"+$.param(oParams);
document.body.appendChild( iframe );
},
"fnSelect": null,
"fnComplete": null,
"fnInit": null
};
$(document).ready(function() {
// Affichage du tableau avec le détail des entrées
$('#tabDetail').dataTable({
"aaSorting": [[ 1, 'desc' ]],
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"aButtons": [{
"sExtends": "download",
"sButtonText": "EXCEL",
"sUrl": "extranet/scriptPHP/csvGeneral.php"
},{
"sExtends": "download",
"sButtonText": "PDF",
"sUrl": "extranet/scriptPHP/pdfGeneral.php"
}]
},
"sAjaxSource": "extranet/scriptPHP/serverSideGeneral.php",
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "json",
"cache": false
} );
}
}).columnFilter({
aoColumns: [{ type: "text" },
{ type: "date-range"},
{ type: "time-range" , values: ["07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]},
{ type: "select", values: ['muret', 'labarthe']}]
});
});
[/code]
csvGeneral.php code :
[code]
<?php
//envoi des headers csv
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="Detail des entrees.csv"');
// Champs de la base de données
$aColumns = array( 'usager', 'date', 'heure', 'decheterie', 'commune', 'etat');
// Table
$sTable = "te_stats";
// Connexion à la base
include("../inc/gestiondech_config.inc.php");
// Eventuels filtres
$sWhere = "";
if ( $_GET['sSearch'] != "" ){
$sWhere = "WHERE (";
for ( $i=0 ; $i
This discussion has been closed.
Replies
Why it's not sending to the csv script ?
Magali
I don't find solution
I have finally find a solution with method POST of TableTools and DOWNLOAD.
Magali
I have the same problem as you. Export CSV works fine without filter range. When i fill my date range nothing is send to the server but the datatable is updated with the new data. I try the Post method nothing happens. Can you help me please.
Thank you in advance.
Kimi