How to add an id to the first column in datatables

How to add an id to the first column in datatables

MochiMochi Posts: 1Questions: 1Answers: 0
edited November 2021 in DataTables
var home_table = $('#datatable').DataTable();
      $.post(urls[0],{commands:commands[3]},function(home_data_table){
        var row_table = 0;
        while(row_table < home_data_table.length){ 
          t.row.add( [
            home_data_table[row_table].ot_id,
            home_data_table[row_table].ot_date,
            home_data_table[row_table].ot_time_start,
            home_data_table[row_table].ot_time_end,
            home_data_table[row_table].ot_sum_time,
            '<button type="button" class="btn btn-danger btn-sm btn_ot_del" id="'+row_table+'">X</button>'
        ] ).node().id = 'ot_id_del'+row_table;  *****************I would like to add this id just only the first column ***********
        t.draw( false );

          row_table++;
        }   
      },'json');
  }

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Doesn't your first column have an ID? ot_id? It might be worthwhile explaining what you're after, plus, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.