Problem with rendering a column

Problem with rendering a column

EmmyLEmmyL Posts: 3Questions: 2Answers: 0

Hi

I have a problem with rendering a column. I need to convert my string into integer:

"columnDefs": [ {
"targets": 5,
"render": function ( data, type, row ) {
    return parseInt(data);
}

}],

The code works fine but I use dataTables to generate tables on multiple pages and for those pages where there are two columns, the whole table will not work. Is there a way I can make render work only for a table with a specific id? I have tried something like:

"columnDefs": [ {
"targets": 5,
"render": function ( data, type, row ) {
    if ( var table==='inventory_table' ) {
        return parseInt(data)};
     };

But it didn't work.

Answers

  • jvretamerojvretamero Posts: 26Questions: 0Answers: 3

    Can you explain more about your data? It seems that the data of the table 1 column index 5 is different than the data of the table 2 column index 5.

  • EmmyLEmmyL Posts: 3Questions: 2Answers: 0

    Hi!

    The issue was that I initialize dataTables on multiple pages, and on the intended page there are 7 columns, while other pages might have only 2 columns so the page will not work. I solved this by using "targets": -1, then it works on all tabels

This discussion has been closed.