How do I get/set the value of a cell in a row?

How do I get/set the value of a cell in a row?

rodzunrodzun Posts: 6Questions: 4Answers: 0

I´m iterating through the rows of my DataTable with the example I found here in documentation but I want to get the data of the second column, analyze that value and then set my processed value on that cell

tablaProgDetalle.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
 // I suppose here goes the processing and the setting of the cells values.
});

Answers

  • rodolphenrodolphen Posts: 18Questions: 4Answers: 0

    Hello,

    I think you could do this with fnGetData and fnUpdate.
    And get row index with row.index()

    regards

  • ThomDThomD Posts: 334Questions: 11Answers: 43

    The "data" element of a column can be a function that references other columns.

    https://datatables.net/reference/option/columns.data

  • rodzunrodzun Posts: 6Questions: 4Answers: 0

    I found the solution ... here it is:

    $(document).ready(function (){
        var table = $('#example').DataTable();
        
        table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
            var data = this.data();        
            console.log(data);
            
            data[0] = '* ' + data[0];
                    
            this.data(data);
        });
    });
    

    Thank you all!!!

This discussion has been closed.