Quantcast
Viewing all articles
Browse latest Browse all 82167

How can I force the 2nd index of aDataSort to sort 'asc' regardless of the target's sort order?

I'm using DataTables as the main list view of a media player web app. When sorting by "Album" I have `aDataSort` setup to sort by "Album", then by "Track number", and finally by "Title" (in case `trackno` is null). My goal is to always have the tracks in the intended `asc` order, regardless of how the target `album` column is being sorted. Here's what I have for `aoColumns` at index 3, `album` :

{	"sName": "album",  "sClass": "album", "aDataSort": [ 3, 7, 2 ],    // 3: album, 7: trackno, 8: title
	"mData": function ( data, type, val ) {
		if (type === 'set') {
			if (!_.isString(val)) { val = '' }
			data['album'] = val;
			data['album-sort'] = _.toSortString(val);
			data['album-display'] = _.toTitleCase(val);
			return;
		}
		else if (type === 'display') { return data['album-display']; }
		else if (type === 'sort') { return data['album-sort']; }
		return data['album'];
	},
},

And for index 7, `trackno` :

{	"bVisible": false,  "sName": "trackno", "asSorting": [ "asc" ],
	"mData": function ( data, type, val ) {
		if (type === 'set') {
			if (_.isUndefined(val) || _.isNull(val) || ''+val === '-1') { val = 99 }
			data['trackno'] = Math.floor(val);
			return;
		}
		return data['trackno'];
	}
},

Sorting the "Album" column by `asc` works as I'd expect, however when I click again to sort `desc` things aren't quite right. It correctly sorts the initial `album` column by `desc` but it's also doing the second round of sub-sorting in `desc` even though I have `trackno` 's `asSorting` set to `["asc"]` .

How can I force the the `trackno` column to always be `asc` even when being used in other columns multisorting?

Viewing all articles
Browse latest Browse all 82167

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>