I would like to know the correct way to update/redraw a table row using the new API. Old questions suggest table.fnUpdate
. Should I still be using the old API for this?
The new API tells me nothing about updating rows.
Thanks in advance!
Update and Delete Rows in a DataTable 1 For Each dr As DataRow In ds.Tables (0).Rows 2 If (dr ("Name") = "Mahesh" Then 3 dr.Delete () 4 End If 5 ds.Tables (0).AcceptChanges () 6 Next
An alternative to row ().data () is to use row ().invalidate (). This discussion has been closed.
So in order to update a row I wanted to identify the row to be updated by some identifier may be a row id and perform the update of the coumns in that specific row. How can I achieve this. I tried fnupdate but seems to have depricated. You can update row data with row ().data ().
For setting the data newData has to either be an array or object, you need to make sure it matches the type of data you've used for the table. If this doesn't match then it wont work. An alternative to row ().data () is to use row ().invalidate ().
if you have set specific id attribute for your rows with Datatable method , then you can select with :
table.row('#row_'+ idRow).data(rowData).draw()
Because generation of id attributes must be like this to be selected by after :
Ex id 3:
// In php : push the key 'DT_RowId' foreach row
foreach ($items as $item) {
$item['DT_RowId'] = 'row_' . $id;
}
After you have specific id and you can select easily for an update :
<tr id="row_3" class="...">
....
</tr>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With