http://www.datatables.net/docs/DataTables/1.9.4/#fnUpdate
原文:
fnUpdate (mData, mRow, iColumn, bRedraw, bAction) → {int}Update a table cell or row - this method will accept either a single value to update the cell with, an array of values with one element for each column or an object in the same format as the original data source. The function is self-referencing in order to make the multi column updates easier.
Parameters:
Name | Type | Attributes | Default | Description | |
---|---|---|---|---|---|
1
| mData | object | array | string | Data to update the cell/row with | ||
2
| mRow | node | int | TR element you want to update or the aoData index | ||
3
| iColumn | int | Optional | The column to update (not used of mData is an array or object) | |
4
| bRedraw | bool | Optional | true | Redraw the table or not |
5
| bAction | bool | Optional | true | Perform pre-draw actions or not |
Returns:
0 on success, 1 on error
Example:
1
2
3
4
5
|
$(document).ready(
function
() {
var
oTable = $(
'#example'
).dataTable();
oTable.fnUpdate(
'Example update'
, 0, 0 );
// Single cell
oTable.fnUpdate( [
'a'
,
'b'
,
'c'
,
'd'
,
'e'
], 1, 0 );
// Row
} );
|
当使用fnUpdate更新一条数据时,更新完后会刷新页面,当存在分页时就会显示首页,但是只要设置参数4和5就不会出现这种情况了,会依然停留在当前页面。
staffTable.fnUpdate([ rowData[0], rowData[1], rowData[2], rowData[3], rowData[4], rowData[5],activate, operate ],$tr[0],false,false);