Cell update

Cell update

mauro218mauro218 Posts: 9Questions: 5Answers: 0

Hello,

I am migrating code from DataTables 1.8 to 1.10

Current 1.8 code:

oTable = $('.dataTable').dataTable();               
                
                    //Loop through each checkbox checked and update
                    $(".Active_Checks:checked").each(function() {
                
                        var iId = $(this).parent().parent().attr("id"); /* Record ID */
                        var indexOfRow = oTable.fnGetPosition( $(this).closest('tr').get(0) );
                        var iStatus = object.value;
        
                        if (iStatus == "Add_MB") {
                            var iIcon = "<img src='/img/greenCheck.gif' border=0>";
                            oTable.fnUpdate( iIcon, indexOfRow, 2 );
                        } 
                        if (iStatus == "Add_BP") {
                            var iIcon = "<img src='/img/Checkpurple.gif' border=0>";
                            oTable.fnUpdate( iIcon, indexOfRow, 3 );
                        }       
                        if (iStatus == "Remove_MB") {
                            oTable.fnUpdate( "", indexOfRow, 2 );
                        } 
                        if (iStatus == "Remove_BP") {
                            oTable.fnUpdate( "", indexOfRow, 3 );
                        }
                    
                        jQuery.ajax({
                             type: "POST",
                             url: "/Online/docs_actions.lasso",
                             data: "status="+iStatus+"&row_id="+iId,
                             dataType: "html"
                         });                
                    });
                    oTable.fnDraw();

I can't find a way to update the cell contents in 1.10. What's the best way to change the code?

Thank you in advance!

Jhonny

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi Jhonny,

    cell().data() is the way to update individual cells in 1.10's API (note you need to use $().DataTable(), capital D to get the new API) . A conversion guide is available here.

    The 1.9- API should still work in 1.10 though!

    Allan

This discussion has been closed.