Is there a way to disable the default warnings?

Is there a way to disable the default warnings?

mmcnair80mmcnair80 Posts: 83Questions: 21Answers: 7

I have modified the ssp.class.php (and changed it's name to FilterSort.class.php). I added the ability to have multiple search values in a single search box using the Individual Column Searching Text Input. I made it so that you can separate your search values with a ; and it'll search for each of those values. When I do this for a date as I'm typing in the date I get a warning that the SQL is not working. I get this popup from DataTables:

DataTables warning: table id=DataTableEdit - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

and this in the Preview on the developer tab in Firefox:

{"error":"A SQL error has occurred: SQLSTATE[22007]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Conversion failed when converting date and\/or time from character string. 1 1 1"}

When I finish typing out the date, however, I don't get the errors it just does the search.

Is there a way to keep the errors from popping up while I'm still typing in the date? or delay the search till I'm done typing so that I don't get the error?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Answer ✓

    Possibly your best option is to change the column filtering code that you are using to listen for a return key and only at that point execute the column().search() method. e.keyCode == 13 should do it (where e is the event).

    Allan

  • mmcnair80mmcnair80 Posts: 83Questions: 21Answers: 7
    edited February 2017

    @allan
    Here is how I am currently initializing my DataTables:

        $(document).ready(function ()
        {
            // Setup - add a text input to each footer cell
            $('#DataTable tfoot th').each(function ()
            {
                var title = $(this).text();
                $(this).html('<input type="text" placeholder="Search ' + title + '" />');
            });
    
            var table = $('#DataTable').DataTable({
                "lengthMenu": [[25, 50, 75, 100, 150, -1], [25, 50, 75, 100, 150, 'All']],
                "dom": '<"top"Bifpl<"clear">>rt<"bottom"ip<"clear">>',
                "buttons": [{
                    extend: 'collection',
                    text: 'Export',
                    buttons: ['export', { extend: 'csv',
                        text: 'Export All To CSV',
                        action: function (e, dt, node, config)
                        {
                            window.location.href = './ServerSide.php?ExportToCSV=Yes';
                        } 
                    }, 'csv', 'pdf', { extend: 'excel',
                        text: 'Export Current Page',
                        exportOptions: {
                            modifier: {
                                page: 'current'
                            }
                        },
                        customize: function (xlsx)
                        {
                            var sheet = xlsx.xl.worksheets['sheet1.xml'];
                            $('row:first c', sheet).attr('s', '7');
                        }
                    }]
                }
                ],
                "fixedHeader": {
                    header: true,
                    footer: true
                },
                "select": true,
                "processing": true,
                "serverSide": true,
                "ajax": {
                    "url": "./ServerSide.php",
                    "type": "POST"
                },
                stateSave: true,
                columnDefs: [{ visible: false, targets: 0}],
                initComplete: function ()
                {
                    var api = this.api();
    
                    // Apply the search
                    api.columns().every(function ()
                    {
                        var that = this;
    
                        $('input', this.footer()).on('keyup change', function ()
                        {
                            if (that.search() !== this.value)
                            {
                                that
                                  .search(this.value)
                                  .draw();
                            }
                        });
                    });
                }
            });
        });
    

    So you are saying that I should change the

    $('input', this.footer()).on('keyup change', function() to

    $('input', this.footer()).on('keyup change', function(e)
    and add after that something like

    if (that.search() !== this.value & e.keyCode == 13)?

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Basically yes :smile:

  • mmcnair80mmcnair80 Posts: 83Questions: 21Answers: 7

    This did work. The search now waits for the user to hit Enter.

This discussion has been closed.