1

I created an html page, which contains five columns. The last one contains a button. (Each row has a button in the last column).

I'm using datatables plugin:

var oTable = $(".datatable-fn").dataTable({
    sPaginationType: "full_numbers"
});

Now I need to add new row to the tables. I know that exists fnAddData function that do this, but I don't know how can I add the button in the last cell of the row.

1 Answer 1

3

You can add any HTML content in the new cells:

$('#example').dataTable().fnAddData( [
    giCount+".1",
    giCount+".2",
    giCount+".3",
    "<button>My button</button>" ] );

Using createElement:

var button = document.createElement("button");
button.innerHTML = "My button";

$('#example').dataTable().fnAddData( [
    giCount+".1",
    giCount+".2",
    giCount+".3",
    button.outerHTML  ] )
Sign up to request clarification or add additional context in comments.

1 Comment

So simple? :D Can I define a more complex object, using createElement, and then pass the object to the fnAddData?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.