columnDefs.createdcell settings lost after edit

columnDefs.createdcell settings lost after edit

hbanaharishbanaharis Posts: 32Questions: 14Answers: 3

Hi

I'm using columnDefs.createdcell in this way:

    "columnDefs": [
                             { className: "1stconc", "targets": [ 6 ] },
                         {
                        "targets": 6,
                        "createdCell": function (td, cellData, rowData, row, col) {
                            $(td).html($('<div class="progress"><div class="progress-bar" aria-valuenow="'+cellData+'" aria-valuemin="50" aria-valuemax="100" style="min-width:15px; width:'+cellData+'%">'+cellData+'</div></div>'));
                            if ( cellData >=35 ) {
                                $(td).children().children().addClass("bg-success");
                                };

When I edit the cell contents the css formatting is lost. How can I preserve (and update formatting) to reflect new cell value?

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    I believe columns.createdCell only runs when the cell is first created. You may need to use rowCallback to update the formatting after each draw.

    Kevin

  • hbanaharishbanaharis Posts: 32Questions: 14Answers: 3

    Hi Kevin. I see. That would suggest I would have to duplicate the columnDefs rules under rowCallback. Is there a way to refresh the columnDefs when an edit is made without reloading the whole dataset (eg just reload the current records displayed)?

This discussion has been closed.