Responsive - Requires order: dt object to work?

Responsive - Requires order: dt object to work?

JoyrexJoyrex Posts: 92Questions: 14Answers: 3

I am attempting to use the Responsive extension for DataTables, and I notice that until I added order: to the DataTables object, the responsive column wouldn't show properly (would ignore the orderable: object on columnDefs for the responsive control column).

See my example here: http://live.datatables.net/yajamuvo/1/edit?html,js,output

(Mind, for some reason the responsive controls is not working here either, despite having invoked it correctly from what I can tell, but you can remove the order: object, and the responsive column does not display correctly.)

This is a bit frustrating, since in some cases I want my query output (what populates my DataTable) to determine the default sort order. Not a deal-breaker, but if this is a bug and can be resolved, all the better.

On a side note, I notice the documentation for responsive makes mention of a no-wrap class to be added optionally to the table - this is not correct, as the correct class is actually nowrap (minus the hyphen).

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,852Questions: 1Answers: 10,519 Site admin

    I'm not quite getting it I'm afraid.

    This is the example without the order option. As expected, the first column is the ordering column since, as the documentation notes, columns.orderable only effects the end user's ability to order the column, not the API's (thus the default of [[0, 'asc']] is used.

    Use order: [] if you don't want a default order.

    Allan

  • JoyrexJoyrex Posts: 92Questions: 14Answers: 3

    Allan,

    OK, by studying your example, I found out why my example wasn't working - JSFiddle included the Responsive JS and CSS BEFORE the jQuery/DataTables JS/CSS files. Putting them in the correct order caused the Responsive plugin to work with or without the order option.

    The reason I brought this up was in the application I am working on (which I cannot post a link to since it's internal), I am using the same setup, but the Bootstrap 4 skins thrown into the mix (yes, I know it's not finalize, as is Bootstrap 4 itself). Would the lack of a Responsive CSS/JS files for Bootstrap 4 be causing my issue? I am using the normal DataTables CSS/JS files, and they are in the correct order.

    Again, the responsive column ignores the orderable: false option unless I have the order: specified, but passing it a blank array is a good workaround, so thanks for that!

  • allanallan Posts: 63,852Questions: 1Answers: 10,519 Site admin
    Answer ✓

    Yes - its very probable that if the Bootstrap 4 / Responsive CSS file isn't loaded, then Responsive might just not work at all.

    Bootstrap 4 files are available for all DataTables extensions, and they are available on the CDN, they just aren't included in the download builder yet (and won't be until Bootstrap 4 goes at least beta).

    Allan

This discussion has been closed.