Column widths - Individual column searching (select inputs)

Column widths - Individual column searching (select inputs)

PKCDavidPKCDavid Posts: 2Questions: 1Answers: 0

I have managed to implement a data table, with filtering, as per the following page:-
https://datatables.net/examples/api/multi_filter_select.html

I can size the columns using CSS or columnDefs-as long as I am making the columns wider than the longest item in the select filter control. However, I cannot make the columns narrower than the widest value in the select box.

Another colleague has created a dashboard and he has asked me to solve this problem. Some columns are really wide, for example, a notes column, where we want to reduce the width of the column (obviously, when you drop down the filter select box, that box will be wide and that's okay).

Thanks

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    See if this thread helps.

    Kevin

  • bahruzqasimovbahruzqasimov Posts: 1Questions: 0Answers: 0

    My solution it works for me
    initComplete: function () {
    this.api().columns(3).every( function () {
    var column = this;
    var select = $('

    Filter by company Filteri sil

    ')
    .appendTo( ".dt-buttons" );
    $( "#selectf" ).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 ) {
                    $("#selectf").append( '<option value="'+d+'">'+d+'</option>' )
                } );
            } );
        }//initComplete
    
This discussion has been closed.