gpt4 book ai didi

javascript - DataTables - 如何从特定行获取单元格?

转载 作者:行者123 更新时间:2023-11-30 20:07:40 25 4
gpt4 key购买 nike

每一行都有一个 ID,#row-(id from ajax)。现在我想按 id 选择一行,我让它工作了。

var row = verzondenTable.row('#row-' + k);

k = 来自 ajax 的 key 。

每个 td 的每列都有一个类,因此第一列有类 .td-subject,第二列有 .td-open

我想从选定的特定行中选择 .td-open 单元格并为其设置数据。

代码:

$().ready(function() {
var verzondenTable = $('#tblVerzondenItems').DataTable({
"order": [[0,'desc']],
"columnDefs":[
{ "type": "date-nl", "targets": [ 'th-datum' ] },
{
sortable: false,
targets: [6,7]
}
],
"initComplete": function(settings, json) {
$.ajax({
url : '/mail/feed/mailgun.json',
type : 'GET',
dataType:'json',
success : function(data) {
$.each(data, function(k,v) {

var row = verzondenTable.row('#row-' + k);
verzondenTable.row('#row-' + k).cell('.td-open').data((v['open_rate'] * 100).toFixed(2) + '%');

});
$('#alert-mailgun').alert('close');
},
error : function(request,error)
{
alert("Request: "+JSON.stringify(request));
}
});
}
});
// loop over each element and create a tooltip using the data-attribute
$('.count').each(function() {
Tipped.create(this, {
ajax: {
data: $(this).data('querystring'),
type: "POST"
},
maxWidth: 300,
skin: 'dark'
});
});
});

最佳答案

如果你想通过 API 你可以做类似的事情

var row = verzondenTable.row('#row-' + k);
row.nodes().to$().find('.td-open').text((v['open_rate'] * 100).toFixed(2) + '%');
row.draw().invalidate();

nodes() -> 获取所有节点
to$() -> 转换为 jQuery 实例
无效 -> 更新 DT 内部结构

关于javascript - DataTables - 如何从特定行获取单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52718702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com