Getting started with datatable

Getting started with datatable

yunis324yunis324 Posts: 2Questions: 1Answers: 0

Good afternoon, I am learning to use datatable and I have a problem.

I want to add a condition to my table where the user can choose a date range and have it sorted in the table but I can't do it

Answers

  • yunis324yunis324 Posts: 2Questions: 1Answers: 0

    function listar(){
    tabla=$('#tbllistado').dataTable({
    "bProcessing": true,//activamos el procedimiento del datatable
    "bServerSide": true,//paginacion y filrado realizados por el server
    dom: 'Bfrtip',//definimos los elementos del control de la tabla
    buttons: [
    'copyHtml5',
    'excelHtml5',
    'csvHtml5',
    'pdf'
    ],
    "ajax":
    {
    url:'../ajax/entrada_empresa.php?op=listar',
    type: "get",
    dataType : "json",
    error:function(e){
    console.log(e.responseText);
    }
    },
    "bDestroy":true,
    "iDisplayLength":10,//paginacion
    "order":[[0,"desc"]]//ordenar (columna, orden)
    }).DataTable();
    }

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Since you have server side processing enabled you will need to send the date range input values to the server using ajax.data as a function, like this example. Next you will need to update your server side script to incorporate the range parameters into the data query used to fetch the row data.

    Kevin

Sign In or Register to comment.