Autofill does not work if filtered or searched

Autofill does not work if filtered or searched

YoDavishYoDavish Posts: 123Questions: 46Answers: 3

Editor 1.9.4
DataTables 1.10.21
Latest version of KeyTable and AutoFill

My code is pretty similar to this

Example of problem:
1. I click on drop down filter under "Assign To" column and select "User 1".
2. Then in the first row, I change "User 1" to "User 2" and then try use the AutoFill feature to drag across multiple rows.
3. AutoFill pops up a notification saying, "Fill in all cells with "User 1" rather than "User 2"
This problem also occurs if you search for the value in the search box and repeat steps 1 and 2. Is something I can add that fixes this?

Code below:

editor = new $.fn.dataTable.Editor({
        table: '#billingErrors',
        ajax: "tableServer-billingErrors.php",
        fields: [
        <?php 
        if(in_array("BILLINGERRORADMIN", $_SESSION['userRoles'])){
            echo "{
                label: 'Assigned To',
                name:  'assigned_to',
                type:  'select',
                options: [
                    { label: 'Empty',               value: '' },
                ]
            },";
        }
        ?>
            {
                label: "Note",
                name: "note",
                type: "textarea"
            },
            {
                label: "Completed",
                name: "completed",
                type: "select",
                options: [
                    { label: "Empty Status",    value: ""},
                    { label: "YES",             value: "YES"},
                    { label: "NO",              value: "NO"},
                    { label: "RETURN",          value: "RETURN"}
                ]
            }
        ]
    });

    tab = $("#billingErrors").DataTable({
        ajax: "tableServer-billingErrors.php",
        dom: 'Bfilrtilp',
        columns: [
            { data: "specnum_formatted" },
            { data: "patName" },
            { data: "valid_comment" },
            { data: "assigned_to" },
            { data: "completed" },
            { data: "client_name" },
            { data: "created_date" },
            { data: "accession_date" },
            { data: "client_code" },
            { data: "specclass_id" },
            { data: "note" }
        ],
        colReorder: true,
        searching: true,
        autoFill: {
            <?PHP 
                if(in_array("BILLINGERRORADMIN", $_SESSION['userRoles'])) 
                    echo "columns: ':nth-child(4),:nth-child(5),:nth-child(11)',"; 
                else 
                    echo "columns: ':nth-child(5),:nth-child(11)',"; 
            ?>
            editor:  editor
        },
        keys: {
            <?PHP 
                if(in_array("BILLINGERRORADMIN", $_SESSION['userRoles'])) 
                    echo "columns: ':nth-child(4),:nth-child(5),:nth-child(11)',"; 
                else 
                    echo "columns: ':nth-child(5),:nth-child(11)',"; 
            ?>
            editor:  editor
        },
        select: {
            style:    'os',
            selector: 'td:first-child',
            blurable: true
        },
        buttons: [
            {extend: "create", editor: editor }, 
            {extend: "edit",   editor: editor }, 
            'copy', 'csv', 'excel', 'pdf', 'print'
        ],
        initComplete: function(){
            tab.order([6,"desc"]);
            tab.draw();
            this.api().columns().every( function(){
                var column = this;
                var select = $('<select><option value=""></option></select>')
                    .appendTo( $(column.header()))
                    .on( 'change', function () {
                        var val = $.fn.dataTable.util.escapeRegex(
                            $(this).val()
                        );
                        column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                });
                column.data().unique().sort().each( function ( d, j ) {
                    select.append('<option value="'+d+'">'+d+'</option>' )
                });
                $('select', this.header()).click(function(event){
                    event.stopPropagation();
                });
            });
        },
        lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
        pageLength: -1
    });

Answers

  • YoDavishYoDavish Posts: 123Questions: 46Answers: 3

    I tested this on the autofill and key example with the editor which can be found here:

    https://editor.datatables.net/examples/extensions/excel

    If you enter in "Tokyo" in the search box, then change "Tokyo" in the first row to "TEST" and try to drag and autofill "TEST" for all the other rows that contained "Tokyo". It will try to fill it with "Tokyo" still. Is there not a way to autofill on filtered or search columns quickly?

  • YoDavishYoDavish Posts: 123Questions: 46Answers: 3

    Found an alternate solution. Using SearchPanes to perform the searches allows you to then make changes even on the searched data.

This discussion has been closed.