Peacefull Peacefull - 3 months ago 22
jQuery Question

DataTables add data in row dynamically after validate button

In my project I'm trying to add label (ex:

OK
or
NOK
) in the row at column Validate using DataTables but i can't manage it.

When i click on Open a new modal appear and then when i click on the content button HVV i would like to add a label in the column Validate (see pictures). How i can do that please ?

JSFiddle demo : https://jsfiddle.net/9ecb3sxr/

enter image description here
enter image description here

Answer
  1. Remove data: null for last column, add defaultContent: ''.
  2. Pass row Id to modal as data property data-row-id="' + rowIdx + '".
  3. Upon closing the modal, update the required column:

    var rowIdx = $(event.target).data('row-id');
    $("#dispo").DataTable()
        .cell({ row: rowIdx, column: 3})
        .data('<div class="label label-success">Valid</div>')
        .draw(false);
    

I don't understand the logic with OK/NOK states but you should get an idea and adjust the code accordingly.

See updated jsFiddle for code and demonstration.

Comments