数据表 fn 用新值更新行 [英] dataTable fnUpdate row with new value

查看:22
本文介绍了数据表 fn 用新值更新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数据表并且在 table

I am using datatables and have this tr element in table

<tr class="gradeA even row_selected" id="3692">
  <td class=" sorting_1">3692</td>
  <td class="">koza</td>
  <td class="" title="10:12:30">2013-12-31</td>
  <td class="">2014-02-06</td>
  <td class="">FULL packet</td>
  <td class="">NONE</td>
  <td class="">Name</td>
</tr>

我想使用 fnUpdate 函数更新第 1 个和第 4 个 td 元素.我试图只更新一个 td,但它没有更新.
在 Chrome 中,控制台日志我收到此错误:

I would like to update 1st and 4th td element using fnUpdate function. I have tried to update for only one td but it does not update.
In Chrome, console log I am getting this error:

未捕获的类型错误:无法设置未定义的属性_aData"

Uncaught TypeError: Cannot set property '_aData' of undefined

这是我尝试过的:

 // dynamically update row
 $('#example').dataTable().fnUpdate( ['Zebra'], parseInt('3692'));

3692td 元素的 id 来知道我需要更新哪一行,而 zebra 是要更改的值.我知道我没有包含要更新的单元格,但我不知道该怎么做.在datatables api上,给出了以下示例:

3692 is the id of the td element to know which row I need to update, and the zebra is the value to change. I know that I have not included which cell to update but I don't know how to do that. On datatables api, following example is given:

oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], 1 ); // Row

推荐答案

请查看此处的文档 http://datatables.net/api

您的问题不完整,因为您需要指定要修改的列 (td),但这是我要尝试的(假设您要更新第二列).

Your question is not complete, as you need to specify what column(td) you want to modify, but here's what I would try (assuming you want to update the second column).

$('#example').dataTable().fnUpdate('Zebra' , $('tr#3692')[0], 1 );

第二个参数是行,第三个是列.

The second parameter will be the row, and the third is the column.

请注意,我传入了一个字符串.

Note that I passed in a string.

这篇关于数据表 fn 用新值更新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆