Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35270

Load ajax data with custom parameters

$
0
0

Hi to all!

In my datatable i pass few custom parameters (ex: values of input fields).
But if i change the value of the input fields, and reload the table, the new values are not taken...


<script type="text/javascript">
tblPreventivi = $('#dt_basic').DataTable({
    "processing": true,
    "serverSide": true,
    "order": [[0, "desc"]],
    "ajax": {
        url: "?modulo=Preventivo&action=getPreventiviNew&ajxRq=1",
        data: {
            "dtStart": $("#dtStartAlternate").val(),
            "dtEnd": $("#dtEndAlternate").val(),
            "provincia": $("#selProvincia").val(),
            "inviati": $("input[name=preventiviinviati]:checked").val()
        }
    },
    "columns": [
        {data: {
                _: "id.display",
                sort: "id.tosort"
            }},
        {data: {
                _: "datapreventivo.display",
                sort: "datapreventivo.timestamp"
            }},
        {data: {
                _: "datamodifica.display",
                sort: "datamodifica.timestamp"
            }},
        {data: "nome"},
        {data: "email"},
        {data: "telefono"},
        {data: "citta"},
        {data: "provincia"},
        {data: "opzioni"},
    ],
    "sDom": "<'dt-toolbar'<'col-xs-12 col-sm-3 col-sm-offset-9'f>>r" +
            "t" +
            "<'dt-toolbar-footer'<'col-sm-3 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-9'>p>",
    "autoWidth": true,
    "preDrawCallback": function() {
        // Initialize the responsive datatables helper once.
        if (!responsiveHelper_dt_basic) {
            responsiveHelper_dt_basic = new ResponsiveDatatablesHelper($('#dt_basic'), breakpointDefinition);
        }
    },
    "columnDefs": [
        {"orderable": false, "targets": 8},
        {"orderable": false, "targets": 1}
    ],
    "rowCallback": function(nRow) {
        responsiveHelper_dt_basic.createExpandIcon(nRow);
    },
    "drawCallback": function(oSettings) {
        responsiveHelper_dt_basic.respond();
    },
    "language": {
        "url": "accessories/DT-IT.txt"
    }
});
</script>

The initial value of the dtStart, dtEnd etc.. parameters is "", and it's ok, but when i change the value:


<script type="text/javascript">
$(document).on("change", ".datepicker", function(event) {   
    tblPreventivi.ajax.reload();
});
</script>

the new value are not taken...

How i can do this?

Datatables 1.10

Thanks in advance.

Massimo


Viewing all articles
Browse latest Browse all 35270

Trending Articles