Default ordering of SearchPanes affected by order defined in defaults

Default ordering of SearchPanes affected by order defined in defaults

TrilceACTrilceAC Posts: 18Questions: 6Answers: 0

I'm using datatables to create a monitoring webapp for an automated data processing. The webapp includes different pages where objects of a particular type are rendered on each page. Independently of the page/object type, there are some common patterns, like an incremental id that is rendered as the first column of the table. The most interesting objects are the most recent ones: It makes sense to order the table by id in a desc order by default. Therefore, I decided to use defaults, which among other defaults, includes the ordering:

$.extend(true, $.fn.dataTable.defaults, {
  order: [0, 'desc']
});

This affects the search panes default ordering: Now all the panes are desc ordered by default, which is a bit awkward. This example shows the behaviour that I am describing.

I have removed the order from defaults and put it back into each datatable constructor. When the order is defined at the constructor instead of at defaults, the search panes are not desc ordered, as shown here.

Is this a bug or a feature? Is there any way to set the default ordering of a search pane?

Thanks,
Carlos

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    It's a feature. SearchPanes are just DataTables - so if you modify the default for your main tables, that will also affect any panes as well.

    The only solution would be to put it into the constructor, as you are doing, I'm afraid,

    Colin

This discussion has been closed.