How To Hide SearchBox when its on Responsive Windows ( Yajra Datables on Laravel )

Viewed 16

sorry guys, maybe my question is not clear. i will try to explain it with my best.

search box before

search box after

i'm learning yajra datatables on laravel, but i found a problem while doing some experiment, can i hide or remove that search box ( search box after ) ? sorry for my bad english

this is the code :

@endsection
@section('js')
<script type="text/javascript">
    $('.yajra-datatable thead th').each(function() {
        var title = $('.yajra-datatable tfoot th').eq($(this).index()).text();
        if (title != "") {
            $(this).html('<input type="text" placeholder="Search ' + title + '" />');
        }
    });
    // DataTable
    var table = $('.yajra-datatable').DataTable({
        columnDefs: [{
            searchable: false
            , targets: [0, 6]
        }, {
            className: 'dt-body-center'
            , targets: [0, 1, 2, 3, 4, 5, 6]
        }, {
            className: 'dt-head-center'
            , targets: [0, 1, 2, 3, 4, 5, 6]

        }]
        , dom: 'lrtip'
        , rowReorder: {
            selector: 'td:nth-child(2)'
        }

        , responsive: {
            details: true
        }
        , processing: true
        , serverSide: true
        , ajax: "{{ route('students.list') }}"
        , columns: [{
                    data: 'DT_RowIndex'
                    , name: 'DT_RowIndex'
                }
                , {
                    data: 'student_id'
                    , name: 'student_id'
                }
                , {
                    data: 'student_name'
                    , name: 'student_name'
                }
                , {
                    data: 'student_gender'
                    , name: 'student_gender'
                }
                , {
                    data: 'student_phone_number'
                    , name: 'student_phone_number'
                }
                , {
                    data: 'student_email'
                    , name: 'student_email'
                }
                , {
                    data: 'action'
                    , name: 'action'
                    , orderable: true
                    , searchable: true
                }
            , ]

        , initComplete: function() {
            var r = $('.yajra-datatable tfoot tr');
            r.find('th').each(function() {
                $(this).css('padding', 8);
            });
            $('.yajra-datatable thead').append(r);
            $('#search_0').css('text-align', 'center');
        }
    , });
    // Apply the search
    table.columns().eq(0).each(function(colIdx) {
        if (!table.settings()[0].aoColumns[colIdx].bSearchable) {
            table.column(colIdx).header().innerHTML = table.column(colIdx).footer().innerHTML;
        }
        $('input', table.column(colIdx).header()).on('keyup change', function() {
            table
                .column(colIdx)
                .search(this.value)
                .draw();
        });
        $('input', table.column(colIdx).header()).on('click', function(e) {
            e.stopPropagation();
        });
    });

</script>

@endsection

0 Answers
Related