search, sorting dont work

search, sorting dont work

volnistii11volnistii11 Posts: 49Questions: 16Answers: 0

Hello, such a problem, the search, sorting, restrictions on the output of records (10,20,30, etc.) do not work for me in the table, although the data is displayed and changed correctly. I looked at the MySQLl logs, there is no information output on the given conditions. What could be the problem (The Russian language can be found in the code, but it does not affect the work of the program in any way)?

classifier.php
`

    <html>
        <head>
        <title>Картотека архива</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="Content-Language" content="ru">
        <link rel="stylesheet" type="text/css" href="../../../../DataTables/datatables.min.css">
        <link rel="stylesheet" type="text/css" href="../../../../DataTables/Editor-PHP-1.9.4/css/editor.dataTables.min.css">
        <script type="text/javascript" charset="utf8" src="../../../../DataTables/datatables.min.js"></script>
        <script type="text/javascript" src="../../../../DataTables/Editor-PHP-1.9.4/js/dataTables.editor.min.js"></script>
        </head>
        <body>
        <div align="center">
            <h1>Журнал учета учтенных экземпляров архивной документации</h1>
            <form action="classifier.php"><button>Обновить</button></form>
            <form action="../../menu.php"><button>Выход</button></form>     
            <br><br>    
        <table id='empTable' class='display dataTable'>

          <thead>
            <tr>
                <th><b>№</b></th>
                <th><b>Наименование <br> документа</b></th>
                <th><b>Обозначение</b></th>
                <th><b>Дата<br>передачи</b></th>
                <th><b>Основание</b></th>
                <th><b>Кому<br>передан</b></th>
                <th><b>Акт №<br>дата</b></th>
                <th><b>Передан<br>через</b></th>
                <th><b>Примечание</b></th>
            </tr>
            </thead>
        <tfoot>
            <tr>
                <th><b>№</b></th>
                <th><b>Наименование <br> документа</b></th>
                <th><b>Обозначение</b></th>
                <th><b>Дата<br>передачи</b></th>
                <th><b>Основание</b></th>
                <th><b>Кому<br>передан</b></th>
                <th><b>Акт №<br>дата</b></th>
                <th><b>Передан<br>через</b></th>
                <th><b>Примечание</b></th>
            </tr>
            </tfoot>

        </table>
        </body>
        </html>
        <script>
        var editor; // use a global for the submit and return data rendering in the examples

    $(document).ready(function() {
        editor = new $.fn.dataTable.Editor( {
            ajax: "query_classifier_edit.php",
            table: "#empTable",
            fields: [ {
                    label: "№:",
                    name: "Number"
                }, {
                    label: "Наименование документа:",
                    name: "DocumentName",
                    type: "textarea"
                }, {
                    label: "Обозначение:",
                    name: "DocumentNumber",
                    type: "textarea"
                }, {
                    label: "Дата передачи:",
                    name: "DateNotice",
                    type: "datetime"
                }, {
                    label: "Основание:",
                    name: "Reason",
                    type: "textarea"
                }, {
                    label: "Кому передан:",
                    name: "Whom",
                    type: "textarea"
                }, {
                    label: "Акт № дата:",
                    name: "Act",
                    type: "textarea"
                }, {
                    label: "Передан через:",
                    name: "WhoTransfered"
                }, {
                    label: "Примечание:",
                    name: "Note",
                    type: "textarea"
                }

            ]
        } );

       // Activate an inline edit on click of a table cell
        $('#empTable').on( 'click', 'tbody td', function (e) {
            editor.inline( this, {

            buttons: { label: '&gt;', fn: function () { this.submit(); } }
            }           );
        } );


       $('#empTable').DataTable({
          'processing': true,
          'serverSide': true,
          "lengthMenu": [[10, 25, 50, 1000000000], [10, 25, 50, "All"]],
          "pageLength": 25,
          select: true,
            dom: 'lBrtip',
            buttons: [
                'excelHtml5'
            ],
            columns: [
                { data: "Number" },
                { data: "DocumentName" },
                { data: "DocumentNumber" },
                { data: "DateNotice" },
                { data: "Reason" },
                { data: "Whom" },
                { data: "Act" },
                { data: "WhoTransfered" },
                { data: "Note" }   
            ],
            language: {
                          "processing": "Подождите...",
                          "search": "Поиск:",
                          "lengthMenu": "Показать _MENU_ записей",
                          "info": "Записи с _START_ до _END_ из _TOTAL_ записей",
                          "infoEmpty": "Записи с 0 до 0 из 0 записей",
                          "infoFiltered": "(отфильтровано из _MAX_ записей)",
                          "infoPostFix": "",
                          "loadingRecords": "Загрузка записей...",
                          "zeroRecords": "Записи отсутствуют.",
                          "emptyTable": "В таблице отсутствуют данные",
                          "paginate": {
                            "first": "Первая",
                            "previous": "Предыдущая",
                            "next": "Следующая",
                            "last": "Последняя"
                          },
                          "aria": {
                            "sortAscending": ": активировать для сортировки столбца по возрастанию",
                            "sortDescending": ": активировать для сортировки столбца по убыванию"
                          },
                          "select": {
                            "rows": {
                              "_": "Выбрано записей: %d",
                              "0": "Кликните по записи для выбора",
                              "1": "Выбрана одна запись"
                            }
                          }
                        },
          'ajax': {
                url:'query_classifier_edit.php',

          },

          initComplete: function () {

                $('#empTable tfoot th').each( function () {
                        var title = $(this).text();
                        $(this).html( '<input type="text" placeholder="Поиск '+title+'" />' );
                    } );

                var r = $('#empTable tfoot tr');
                  r.find('th').each(function(){
                    $(this).css('padding', 8);
                  });
                  $('#empTable thead').append(r);
                  $('#search_0').css('text-align', 'center');
                // Apply the search
                this.api().columns().every( function () {
                    var that = this;

                    $( 'input', this.footer() ).on( 'keyup change clear', function () {
                        if ( that.search() !== this.value ) {
                            that
                                .search( this.value )
                                .draw();
                        }
                    } );
                } );
            }

       });
    });
        </script>`

query_classifier_edit.php

`
<?php

    /*
     * Example PHP implementation used for the index.html example
     */

    // DataTables PHP library
    include( "../../../../DataTables/Editor-PHP-1.9.4/lib/DataTables.php" );

    // Alias Editor classes so they are easy to use
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate,
        DataTables\Editor\ValidateOptions;

    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db , '1ineum_archive_notices' )
        ->fields(
            Field::inst( 'Number' )
                ->validator( Validate::numeric() )
                ->setFormatter( Format::ifEmpty(null) ),
            Field::inst( 'DocumentName' ),
            Field::inst( 'DocumentNumber' ),
            Field::inst( 'DateNotice' )
                ->validator( Validate::dateFormat( 'Y-m-d' ) )
                ->getFormatter( Format::dateSqlToFormat( 'Y-m-d' ) )
                ->setFormatter( Format::dateFormatToSql('Y-m-d' ) ),
            Field::inst( 'Reason' ),
            Field::inst( 'Whom' ),
            Field::inst( 'Act' ),
            Field::inst( 'WhoTransfered' ),
            Field::inst( 'Note' )     
        )
        ->process( $_POST )
        ->json();`

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.