0

We have a DataTables plugin table with lots of jQuery manipulation built on top of it.

We have an 'Insert' row in the footer and would like all of our code to be applied to cells in that row in the same way as cells in the rest of the table. For example, when user clicks a '.date' cell, it turns into a datepicker, etc.

When running the jQuery, it's necessary to set the selected cell (with DataTables functions) so that the plugin knows which cell we're dealing with (and renders its values properly the next time we 'draw' the plugin).

We do this using the following DataTables commands:

selectedCell = dataTable.cell(element);
cellColumn = selectedCell.index().column;
cellRow = selectedCell.index().row;
aRowData = dataTable.row(cellRow).data();
orderID = aRowData['DT_RowId'];
selectedField = aFields[cellColumn];
var selectedCellNode = selectedCell.node();

However, DataTables does not recognize these commands when the code is run from a table tfooter td cell. Get the following error:

"Uncaught TypeError: Cannot read property 'column' of undefined"

I tried using table.footer(), column.footer(), etc but those just returned html(). I want to actually set this as the 'selected cell' so that I can manipulate it using dataTables functions, as I do for all others.

Is this possible?

Note: I've already posted on DataTables forum but did not receive any answers. I hope StackOverflow can come to the rescue again :-)

Thank you very much.

user3281588
  • 92
  • 3
  • 8
  • 2
    create a fiddle for the question please – Gayathri Mohan Jul 12 '16 at 02:06
  • 2
    It sounds like you're trying to run those commands on a cell in the ``. I think those are not processed the same as the `` cells by DataTables, so it isn't going to set `selectedCell` correctly, which is why you get that error message (the next line doesn't recognize the `selectedCell.index().column` accessor). As far as I know, the DataTables cell functions don't work on the footer (I could be wrong though). – Chris H. Jul 12 '16 at 15:39
  • So is there any possible way to create a dataTables row that accepts the dataTables functions but is excluded from the sort? I've tried placing the row in a separate tbody (bad idea anyway)...and it doesn't accept the dataTables functions. I've tried adding the row in the dataTables initialization callback, which removes it from the sort but doesn't accept the dataTables functions. Any way to do BOTH? Thanks. – user3281588 Jul 15 '16 at 13:26

0 Answers0