0

I'm getting my first row:

var lFirstRow = self.table.fnGetData($('#' + self.idResultGrid() + ' tbody tr:eq(0)')[0]);

And trying to append to my table:

$('#' + self.idResultGrid() + ' tbody').append(lFirstRow);

Doesn't work, any idea why?

6
  • When you say it doesn't work, do you mean it fails silently or throws an exception? If an exception, what does it say? Commented Sep 8, 2015 at 8:39
  • Could you please add more code or error details to help you out..? Commented Sep 8, 2015 at 8:41
  • I found why it was not adding, cuz lFirstRow is an object, doesn't have a and html elements (<tr><td><input value = 'test'></td></tr>). And now, how can add those <table> elements to my object? Commented Sep 8, 2015 at 8:49
  • @WDS it does not simply do anything! I debug, it passes through, but nothing! Commented Sep 8, 2015 at 8:53
  • @SaviNuclear so do you have any idea how to add a <tr><td> to my object (lFirstRow), that later I could append it to my table? please! Commented Sep 8, 2015 at 9:16

1 Answer 1

1

Generally, you should avoid manipulating the table directly unless really necessary and use appropriate API methods.

SOLUTION

Use fnAddData (DataTables 1.9) or row.add() (DataTables 1.10) to add data to the table:

var lFirstRow = self.table.fnGetData($('#' + self.idResultGrid() + ' tbody tr:eq(0)'));
self.table.fnAddData(lFirstRow);

DEMO

See this jsFiddle for code and demonstration.

Sign up to request clarification or add additional context in comments.

Comments

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.