Datatable + ajax + mysql with filter off the table

Datatable + ajax + mysql with filter off the table

AndersonMoraisAndersonMorais Posts: 1Questions: 1Answers: 0
edited July 2017 in Free community support

I need a datatable + ajax + mysql with filter off the table, have any possibility to do?
My biggest problem is being able to send the post parameters to the search page!

Filter:

<input type="text" name="dt_cadastro_ini" id="dt_inicio01"/>
<input type="text" name="dt_cadastro_fim" id="dt_fim01"/>

JS:

$(function() {
var grid = new Datatable();
grid.init({
src: $("#tabela-resultado-busca"),
onSuccess: function (grid, response) {
},
onError: function (grid) {
},
onDataLoad: function(grid) {
},
loadingMessage: 'Carregando...',
dataTable: {
"bStateSave": true,
"fnStateSaveParams": function ( oSettings, sValue ) {
$("#tabela-resultado-busca tr.filter .form-control").each(function() {
sValue[$(this).attr('name')] = $(this).val();
});
return sValue;
},
"fnStateLoadParams" : function ( oSettings, oData ) {
$("#bt_action tr.filter .form-control").each(function() {
var element = $(this);
if (oData[element.attr('name')]) {
element.val( oData[element.attr('name')] );
}
});
return true;
},
"lengthMenu": [
[10, 20, 50, 100, 150, -1],
[10, 20, 50, 100, 150, "Todos"]
],
"pageLength": 10,
"ajax": {
"url": "mkt_relatorio4_data.php",
},
"order": [
[0, "asc"]
],
buttons: [
{ extend: 'print', className: 'btn default' },
{ extend: 'copy', className: 'btn default' },
{ extend: 'pdf', className: 'btn default' },
{ extend: 'excel', className: 'btn default' },
{ extend: 'csv', className: 'btn default' },
{
text: 'Atualizar',
className: 'btn default',
action: function ( e, dt, node, config ) {
dt.ajax.reload();
}
}
],
}
});
$('#bt_action > li > a.tool-action').on('click', function() {
var action = $(this).attr('data-action');
grid.getDataTable().button(action).trigger();
});
});

This discussion has been closed.