Orthogonal Data and the "Type" Type

Orthogonal Data and the "Type" Type

ajamesajames Posts: 5Questions: 2Answers: 0

DataTables has four built-in data operations:

  • display
  • sort
  • filter
  • type (for type detection data)

I understand the first three - for example, they can be used by a column renderer (example taken from same link as above):

{
    data: 'start_date',
    render: function ( data, type, row ) {
        // If display or filter data is requested, format the date
        if ( type === 'display' || type === 'filter' ) {
            var d = new Date( data * 1000 );
            return d.getDate() +'-'+ (d.getMonth()+1) +'-'+ d.getFullYear();
        }
 
        // Otherwise the data type requested (`type`) is type detection or
        // sorting data, for which we want to use the integer, so just return
        // that, unaltered
        return data;
    }
}

I understand what is meant by type detection in DataTables.

My Question:

Looking at the column renderer code example above, in what circumstances might I want to set the type value to something other than the sort value?

if ( type === 'type' ) {
  // do something different with my data - but what?
}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,451Questions: 1Answers: 10,465 Site admin
    Answer ✓

    in what circumstances might I want to set the type value to something other than the sort value?

    Excellent question. I can't think of one that would be applied in the real world. DataTables does have the ability to perform type specific actions on filtered data (for example, it will strip HTML tags from the data being searched), so the type does have some impact on other operations as well, but it is rarely, if every used (other than the default actions).

    Allan

This discussion has been closed.