jquery datatables: поиск по отдельному столбцу не работает с большим количеством данных - PullRequest
0 голосов
/ 21 июня 2019

Я обработал таблицу с более чем 7000 строками, и теперь при выборе столбца отображаются не все данные, только первые 100, а в некоторых столбцах только 1, но при небольшом количестве данных она работала правильно, однако при передаче ее впроизводство это начало генерировать проблемы

это мой код

 $('#plantsTable').DataTable({
        processing: true,
        serverSide: true,
        ajax:{
            url:"/api/plants/dt",
              data: function ( d ) {
        d.location_id = $('#check_location').val();
          }
        },
        responsive: {
            details: {
                type: 'column',
                target: 'tr'
            }
        },
        columnDefs: [ {
            className: 'control',
            orderable: false,
            responsivePriority: 0,
            targets:   0
        },
            { responsivePriority: -1, targets: -1 }
        ],
        columns: makeColumns(),
        language: {
            search: "_INPUT_",
            searchPlaceholder: "BUSCAR..."
        },
        "lengthMenu": [[ 50,10, 20, 40, 80, 160,-1 ],[ 'Elegir','10', '20', '40', '80', '160','Todo']],
        initComplete: function()
        {
            this.api().columns().every(
                function()
                {
                    var column = this;
                    //added class "select"
                    var select = $('<select class="select" multiple="multiple" PlaceHolder="Buscar..."><option value=""></option></select>')
                        .appendTo($(column.footer())
                            .empty())
                        .on('change', function()
                        {
                            var vals = $('option:selected', this).map(function(index, element) {
                                return $.fn.dataTable.util.escapeRegex($(element).val());
                            }).toArray().join('|');

                            column  .search(vals.length > 0 ? '' + vals + '' : '', true, false)
                                .draw();
                        });

                    column  .data()
                        .unique()
                        .sort()
                        .each(function(d, j)
                        {
                            select.append('<option value="' + d + '">' + d + '</option>')
                        });
                });
            //select2 init for .select class
            $(".select").select2();
        }
    });

моя таблица

<table id="plantsTable" class="table table-bordered display" cellspacing="0" width="100%" >
    <thead>
        <tr>
            <th style="max-width:20px;"> ver</th>
            <th style="max-width:20px;"> Seleccion</th>
            <th style="max-width:200px;" > Codigo MPA</th>
            <th style="max-width:200px;" data-priority="0"> Codigo Planta</th>
            <th style="max-width:200px;"> Cultivar</th>
            <th style="max-width:200px;"> Origen</th>
            <!--th style="max-width:200px;">Condición</th-->
            <th style="max-width:200px;"> T. CBD</th>
            <th style="max-width:200px;"> T. THC</th>
            <th style="max-width:200px;"> Ratio</th>
            <th style="max-width:150px;" data-priority="1"></th>
        </tr>
    </thead>
    <tfoot>
    <tr>
        <th style="max-width:20px;opacity:0;"> Ver</th>
        <th style="max-width:20px;opacity:0;"> Seleccion</th>
        <th style="max-width:200px;" > Codigo MPA</th>
        <th style="max-width:200px;" data-priority="0" >Codigo Planta</th>
        <th style="max-width:200px;"> Cultivar</th>
        <th style="max-width:200px;"> Origen</th>
        <!--th style="max-width:200px;">Condición</th-->
        <th style="max-width:200px;"> T. CBD</th>
        <th style="max-width:200px;"> T. THC</th>
        <th style="max-width:200px;"> Ratio</th>
        <th style="max-width:150px;opacity:0;" data-priority="1"></th>
    </tr>
    </tfoot>
</table>

Я исследовал и, кажется, таблицы данных генерируют сбои согромные объемы данных, есть ли способ решить эту проблему?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...