MCPcopy Create free account
hub / github.com/breck7/scroll / _fnSortData

Function _fnSortData

external/.datatables.js:5590–5625  ·  view source on GitHub ↗
(settings, colIdx)

Source from the content-addressed store, hash-verified

5588 // Get the data to sort a column, be it from cache, fresh (populating the
5589 // cache), or from a sort formatter
5590 function _fnSortData(settings, colIdx) {
5591 // Custom sorting function - provided by the sort data type
5592 var column = settings.aoColumns[colIdx]
5593 var customSort = DataTable.ext.order[column.sSortDataType]
5594 var customData
5595
5596 if (customSort) {
5597 customData = customSort.call(settings.oInstance, settings, colIdx, _fnColumnIndexToVisible(settings, colIdx))
5598 }
5599
5600 // Use / populate cache
5601 var row, cellData
5602 var formatter = DataTable.ext.type.order[column.sType + "-pre"]
5603 var data = settings.aoData
5604
5605 for (var rowIdx = 0; rowIdx < data.length; rowIdx++) {
5606 // Sparse array
5607 if (!data[rowIdx]) {
5608 continue
5609 }
5610
5611 row = data[rowIdx]
5612
5613 if (!row._aSortData) {
5614 row._aSortData = []
5615 }
5616
5617 if (!row._aSortData[colIdx] || customSort) {
5618 cellData = customSort
5619 ? customData[rowIdx] // If there was a custom sort function, use data from there
5620 : _fnGetCellData(settings, rowIdx, colIdx, "sort")
5621
5622 row._aSortData[colIdx] = formatter ? formatter(cellData, settings) : cellData
5623 }
5624 }
5625 }
5626
5627 /**
5628 * State information for a table

Callers 1

_fnSortFunction · 0.85

Calls 2

_fnColumnIndexToVisibleFunction · 0.85
_fnGetCellDataFunction · 0.85

Tested by

no test coverage detected