1.10.4 Columns.data Bug

1.10.4 Columns.data Bug

JamaurJamaur Posts: 87Questions: 10Answers: 0

I recently upgraded from 1.10.2 to 1.10.4, and I noticed columns.data is working differently.

$('#example').dataTable( {
  "columnDefs": [ {
    "targets": 0,
    "data": function ( row, type, val, meta ) {
      // row is an empty object
      // val is undefined
      // meta is undefined
    }
  } ]
} );
  1. The row parameter is an empty object.
  2. The val parameter is undefined.
  3. The meta paramater is undefined.

Could you kindly fix this issue.
Thanks in advance.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin

    Does your actual data function consider the set data type? There is a difference between 1.10.2 and 1.10.3 whereby the set function is called upfront (that it wasn't before was a bug).

    If you aren't considering the set case, you should use the columns.render option as it is readonly.

    Allan

  • JamaurJamaur Posts: 87Questions: 10Answers: 0

    Can you please elaborate on how to use the set case? As the example in columns.data is outdated. Thanks.

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    Answer ✓

    You could do something like:

    data: function ( data, type, val, meta ) {
      if ( type === 'set' ) {
        data.mySotrageOption = val;
        return;
      }
    
      return ...;
    }
    

    If you don't need the ability to use a 'setter' - I would suggest not using columns.data as a function. It adds a lot of code for little benefit.

    Allan

  • JamaurJamaur Posts: 87Questions: 10Answers: 0

    Thanks this helps and yes I need the setter ability. But the meta parameter is still undefined (as I was using meta.col). Does the meta parameter become defined on a particular cirmustance?

  • JamaurJamaur Posts: 87Questions: 10Answers: 0

    Hi,
    I found another issue and posted it on another thread. There is a test case to prove it.

    http://datatables.net/forums/discussion/25846/columns-data-issue-setting-cell-values-more-than-once#latest

This discussion has been closed.