Error datatables requested unknown parameter for row X, column Y when hiding multiple columns

Error datatables requested unknown parameter for row X, column Y when hiding multiple columns

jpujoljpujol Posts: 3Questions: 1Answers: 0

Hi I'm working with a datatable that haves a button which hides a group of columns, i'm also using the responsive extension of datatables, for recalculate the columns width when this changes, the button uses the buttons extension and is defined like this:

{
         extend: 'colvisGroup',
         text: '<b>HIDE MOST</b>',
         hide: function hide(colIdx) {
                  return datatablesMinDisplayColumns.indexOf(colIdx) < 0;
          }
}

datatablesMinDisplayColumns is an array of columns that i will not hide.

The column has a render method, which handles the data null exception, as u can see:

                'render': function (data, type, row) {
                    if (!data)
                        return '<a target="_blank" href="/url">+</a>';
                    else
                        return '<a class="anonymous" href="' + data + '" target="_blank">URL</a>' ;
                }

The problem is when load page if i hit this button the first time will throw this error : datatables requested unknown parameter for row X, column Y pointing to the column with this render method. Then everything will work fine if i hit for the second time. I managed to solve this issue by setting 'defaultContent': '' on this column. But this solution feels like redundant and a work around if i'm already handling this exception. So, i checked the render method doesn't get called when clicking the hide button. So my question is: There can be method trying to get data of a column without calling the render method? This could be related to the responsive plugin i'm using?

Replies

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin

    Could you give me a link to the page you are working on so I can take a look at it please?

    Thanks,
    Allan

This discussion has been closed.