2

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

3
  • Add what label? HVV? Commented Aug 30, 2016 at 13:47
  • From where you are adding label?? Commented Aug 30, 2016 at 13:52
  • Like in my OP post : add label (ex: OK or NOK) then with boot strap i will add class like success or danger. It's just a flag to a status after clicking the HVV button. I hope I'm enough clear :) Commented Aug 30, 2016 at 13:58

1 Answer 1

3
  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.

Sign up to request clarification or add additional context in comments.

5 Comments

the updated fiddle link is having the same issue I guess.
Looks cool now. I owed you because you had helped me long back with an issue :) you rock Brother!!
@Gyrocode.com : your code works good but the problem is with tableResp ! For the jsFiddle i put the the html code directly to the script because i can't use AJAX POST in jsFiddle. This html is the response from my request so i can't add data-row-id="' + rowIdx + '" to it :\ There is another way to do it please ? BTW thank you for this great piece of code !!
@Peacefull, attach data directly to modal window then, see jsfiddle.net/9ecb3sxr/2
@Gyrocode.com : it's wonderful ! thank you very much for helping me ! this last update jsFiddle works for me :) have a good day bro

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.