editable table + add and delete row (addons)

editable table + add and delete row (addons)

emelianenkoemelianenko Posts: 18Questions: 0Answers: 0
edited September 2010 in General
Hello everyone

in the section APIs from the examples, there are case studies for editable tables using a plugin for that, and there are other examples for adding row and also for deleting. The fact is that I need all those 3 things in one table but I am confused as to how I have to add the code there for all that.
For example, this
[code]/* Global var for counter */
var giCount = 1;

$(document).ready(function() {
$('#example').dataTable();
} );

function fnClickAddRow() {
$('#example').dataTable().fnAddData( [
giCount+".1",
giCount+".2",
giCount+".3",
giCount+".4" ] );

giCount++;
}
[/code]
adds a new row, then, where would the deleting row code go? (I cant find it by the way, but I believe to have seen it before) would I have to start another block for $('#example').dataTable(); and the initialisation code for editing rows would again start another instance of $('#example').dataTable();?

thanks a lot

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    To delete a row you need to attach the fnDeleteRow API function ( http://datatables.net/api#fnDeleteRow ) to whatever element (using whatever event) it is that you want to trigger the row being deleted. In my example which the code above comes from, the fnClickAddRow is attached to a link tag, for example.

    For the editable part, you might be interested in this discussion: http://datatables.net/forums/comments.php?DiscussionID=1288 .

    Allan
This discussion has been closed.