koalyptus / TableFilter

A Javascript library making HTML tables filterable and a bit more :)
https://www.tablefilter.com
MIT License
324 stars 95 forks source link

sort_col_at_start also moving column headers based on true or false #725

Closed Guyver1wales closed 5 years ago

Guyver1wales commented 5 years ago

I have a column that is decimal numbers which is the free disk space for all my vmware datastores. All I am trying to do is sort the column from largest number to smallest number.

This correctly filters the column smallest to largest number with the column headers correctly placed at the top of table as normal:

`

` If i then change sort_col_at_start: [3, true] it will correctly sort my column by largest number to smallest but it will also put the column headings at the bottom of the table :( `
<script data-config>
    var filtersConfig = {
        base_path: 'tablefilter/',
        col_1: 'select',
        alternate_rows: true,
        rows_counter: true,
        btn_reset: true,
        loader: true,
        status_bar: true,
        mark_active_columns: true,
        highlight_keywords: true,
        col_types: [
        'string',
        'string',
        'string',
        'formatted-number',
        'formatted-number',
        'number',
        'formatted-number',
        'string',
        'string',
        'string'
    ],
        extensions: [{
            name: 'sort',
            sort_col_at_start: [3, true]
        }]
    };
    var tf = new TableFilter('data', filtersConfig);
    tf.init();
</script>`

why is it doing that??

koalyptus commented 5 years ago

@Guyver1wales not sure if you have multi-line headers, but from what I can see you need to be more explicit about which row is the headers one, have a look to this demo to see how to define headers & filters row: http://www.tablefilter.com/grouped-headers.html

Probably worth starting by only defining the numeric argument in TableFilter constructor. If that's not enough then also define the headers_row_index and/or filters_row_index settings.

Guyver1wales commented 5 years ago

I have a very simple table with one row of table headings row 0)

koalyptus commented 5 years ago

@Guyver1wales this demo shows the sort_col_at_start option in action with a simple table: https://codepen.io/koalyptus/pen/pmXqob Make sure the HTML of your table is conformant/valid, compare it with the HTML of above example. Things like having a thead and tbody sections are important... can't think of anything else otherwise. Failing that please provide a dummy example recreating the issue. Cheers