I use the jquery.datatables plugin along with the FixedColumns add-in and am experiencing some problems keeping two tables in sync.
The first 2 rows of my table contain checkboxes.
Since the data was uploaded using ajax, I returned the “true” or “false” values in the JSON for the flags, and I would use fnRowCallback to dynamically create and replace the “true” or “false” corresponding flag.
Then I added the FixedColumns add-in and, although the table initially loaded correctly, subsequent redraws do not replace the “true” or “false” values with the flags.
Although fnRowCallback still fires, it has only part of the table and only part of the data
Note this code is in TypeScript but resembles JS closely enough to understand without knowing it
fnRowCallback: (row : DataTables.Settings, data: any[], displayIndex: number, displayIndexFull: number) : void => { if($(row).children("td.checkboxColumn").length > 0){ var isFlaggedIdentifier = 'isFlaggedCheckbox_' + displayIndexFull; var isFlaggedCheckbox = $('<input />', { type: 'checkbox', id: isFlaggedIdentifier, 'class': 'tableCheckboxInput', value: isFlaggedIdentifier }); var isFlaggedLabel = $('<label />', { 'for': isFlaggedIdentifier, 'class': 'tableCheckboxLabel' }); var isFlagged: bool = $(row).children("td").eq(1).text() === "TRUE"; var flaggedCheckboxEntry = $(row).children("td").eq(1); if(flaggedCheckboxEntry.hasClass("checkboxColumn")){ flaggedCheckboxEntry.html(isFlaggedCheckbox); flaggedCheckboxEntry.append(isFlaggedLabel); } } }
According to the docs, it seems that FixedColumns does not have fnRowCallback . It has only fnDrawCallback , which only fires once after a table drawn like this, although I have not tried to fix it. I am afraid that this will cause true / false to flash before replacing the checkboxes.
If this assumption is true, what can I do to replace the checkboxes before rendering the table.