Default for aaSorting option should respect aoColumns.asSorting

Default for aaSorting option should respect aoColumns.asSorting

dharknessdharkness Posts: 8Questions: 0Answers: 0
edited January 2010 in Bug reports
I have a table where I set the first column's asSorting to ['desc', 'asc']. However, the table is initially sorted in ascending order. Instead of defaulting to "[[0, 'asc']]", aaSorting should default to "[[0,aoColumns[0].asSorting[0]]]" (or null to have it calculated when the table is initially sorted).

The main problem with this feature request is that it would change the standard behavior for existing code. I would bet a beer that anyone with a table like mine already overrides aaSorting due to this issue, though.

P.S. I didn't see a Feature Request section. Should they go into the General discussion or here?

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hmm - this is a tricky (but good) question! I fully agree that there is a discrepancy here, however fixing it would break a different relationship between asSorting and aaSorting. For example if you have a look at this example: http://datatables.net/examples/basic_init/table_sorting.html - you can see that I've specified the last column in 'desc' to start with. This uses the second option in the sorting array, so if you click on it it then jumps to the first. Basically aaSorting means you don't need to start on the first sorting option in asSorting. Without this interaction you would need to click twice on the column in order to over come this.

    One of these relationships will need to be "broken" I think, in order to keep the flexibility that asSorting and aaSorting provide. I can't really see a way to allow for both that wouldn't break under certain circumstances... What do you think?

    Also, general discussion is fine for this kind of thing :-)

    Regards,
    Allan
  • dharknessdharkness Posts: 8Questions: 0Answers: 0
    I'm not quite sure I follow. My suggestion would take effect only when aaSorting is not provided (or is null). In this case it would use the first asSorting of the first column ('asc' by default) as the default sorting. Even better, if the second element (direction) of any aaSorting element is null or left off, it should use the first direction in that column's asSorting array.

    In your example you provide a full aaSorting array so this change wouldn't affect it AFAICT. In my case I want the default sorting to be the first sorting direction of the first column, but since that isn't 'asc' I need to tell it to use 'desc' twice: once in asSorting and again in aaSorting.
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi dharkness,

    Thanks very much for the clarification - I get it now :-). Yes indeed this is possible if we allow aaSorting to override whatever else goes with asSorting, which I think is the correct thing to do.

    As such I've just implemented what you are looking for and I'll release it along with 1.6.1 shortly :-)

    Regards,
    Allan
This discussion has been closed.