简体   繁体   English

验证按钮后,DataTables在行中动态添加数据

[英]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. 在我的项目中,我试图在使用DataTables的“ 验证”列的行中添加标签(例如OKNOK ),但我无法对其进行管理。

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). 当我单击“ 打开”时,出现一个新的模态,然后当我单击内容按钮HVV时,我想在“ 验证 ”列中添加标签(参见图片)。 How i can do that please ? 请问我该怎么做?

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

在此处输入图片说明 在此处输入图片说明

  1. Remove data: null for last column, add defaultContent: '' . 删除data: null最后一defaultContent: '' data: null ,添加defaultContent: ''
  2. Pass row Id to modal as data property data-row-id="' + rowIdx + '" . 将行ID作为数据属性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. 我不了解OK / NOK状态的逻辑,但您应该有个主意并相应地调整代码。

See updated jsFiddle for code and demonstration. 有关代码和演示,请参见更新的jsFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM