dataTable fn更新带有新值的行 [英] dataTable fnUpdate row with new value

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

问题描述

我使用数据表,并在表格中有这个tr元素

I im 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>

,并希望更新1st和使用fnUpdate函数的第4个td元素。我已经尝试更新只有一个td,但它不更新。在chrome,控制台日志中我收到这个错误:

and 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:

   Uncaught TypeError: Cannot set property '_aData' of undefined 

这是我试过的:

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

3692是td元素的id,用于知道我需要更新哪一行,斑马是价值改变。我知道我没有包括哪个单元格更新,但是我不知道该怎么做。在数据表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.

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

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