How to set the datatable cell value using "oTable.cell($tr, 10).data();" using cell ID

How to set the datatable cell value using "oTable.cell($tr, 10).data();" using cell ID

laxmiparklaxmipark Posts: 22Questions: 8Answers: 0

I have created the Datatable in Jquery. right now I am computing New salary from the input field in the table and getting the New Salary field like this ( which you can see is 11th column). I would like to achieve this using Cell id or className of the cell , not the column number.
here
var New_sal = curr_salary * (1 + 0.01 * Merit_incr);
$tr = var $tr = $(this).closest('tr');
oTable.cell($tr, 10).data(New_sal);

Is it possible?

Thanks

Answers

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin

    Yes - use columns.className to set the class for the column and then use the column selector with a class:

    table.cell( $tr, '.myClassName' ).data( ... );
    

    Allan

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
  • laxmiparklaxmipark Posts: 22Questions: 8Answers: 0

    Hello,
    I have changed as you said I have assigned class to the column as below
    { "data": "New_Salary", className : "New_Slry","title": "New Salary Rounded", className: "dt-heade-center", className: "dt-body-right", render: $.fn.dataTable.render.number(',', '.', 2) },

    oTable.cell($tr, '.New_Slry').data(New_sal);

    This gives me error as in image

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin

    Can you give me a link to the page showing the issue so I can trace it thought please?

    Allan

This discussion has been closed.