How to change the default order in a particular search pane ?

How to change the default order in a particular search pane ?

MelodyNelsonMelodyNelson Posts: 213Questions: 33Answers: 2

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Hi,

I'm using SearchPanes like this :

searchPanes: {
     columns: [15, 1, 2, 3, 13]
}

The column 15 of my table contains years and I would like to change the default order only in this pane. I want a descending order by default for the years.

I didn't find an option to do it (maybe I didn't see it...)

Thanks for your help

Replies

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,953

    I believe you will want to use columns.searchPanes.dtOpts to set the order option the column 15 pane.

    Kevin

  • MelodyNelsonMelodyNelson Posts: 213Questions: 33Answers: 2

    Thanks Kevin.
    I'm not sure I'm doing the right thing.
    I've tried the following code but all the panes disappear, only the links collapse, show and clear the panes are visible on the page.

    searchPanes: {
                columns: [15, 1, 2, 3, 13],
                dtOpts: {
                    order: [15, 'desc']
                }
            }
    
  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited July 2023

    That's close! Here's an example, take a look at the age column, that's similar to what you want. The SearchPanes only have two columns, so you're referring to column 0 - the column with the data.

        columnDefs: [{
          targets: 3,
          searchPanes: {
            dtOpts: {
              order: [0, 'desc']
            }
          }
        }]
    

    Colin

  • MelodyNelsonMelodyNelson Posts: 213Questions: 33Answers: 2

    Thanks a lot Colin.

    It's nice that I can put it in columnDefs, now it's ok with all these defs :

            columnDefs: [
                { visible: false, targets: [1, 15] },
                { render: DataTable.render.number(' ', null, 0, null, ' €'), targets : [9, 10, 12] },
                { searchPanes: { dtOpts: { order: [0, 'desc'] }}, targets: 15}
            ]
    
Sign In or Register to comment.