Reload FixedColumns
Reload FixedColumns
freecex
Posts: 25Questions: 4Answers: 0
Hi everybody. I've got a datatable with first column/row fixed.
Everything works perfect but, if I reload my partial view where my DT is, I encounter this error
Uncaught FixedColumns already initialised on this table
Each time I reload my partial view from menu, I'm doing
if (table != null) {
table.destroy();
}
where table = $('#tbfstorico').DataTable();
Where's my mistake? any idea?
This discussion has been closed.
Answers
Your code seems to work here:
http://live.datatables.net/wifoyeja/1/edit
Please provide a link to your page or a test case replicating the issue. You can update my example.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Hi Kevin,
it's exactly what I've to do, but in my case works only if I reload entire project.
I'm working with partialview, so I got error when I reload only my partial.
Reloading all project works with no problem....
Maybe a bug? What's wrong?
I can provide a demo test, but only next Monday, because I can t expose our internal server.... otherwise... any idea on this?
Without seeing it its hard to say what the problem is. I would place a console log statement in the if statement to make sure the destroy() statement is executed:
Beyond that its hard to say what is happening when you are reloading the partial view.
Kevin
I'll do my best to have a test before Monday...
Yes, I try to put some console.log before and affter destroying table .... everything seems ok (seems... but not!)
Any other idea?
EDIT: Edited for Markdown code formatting.
This is how I load data.
At the beginning, you can see where I check if table exist or not.
Into my console, I got DESTROY and DESTROIED message with no error.
Error appears later.
I was originally thinking you were getting this error:
I don't see anything in that code that would seem to cause the
Uncaught FixedColumns already initialised on this table
error. There are a couple threads on the forum with the error but no resolution. The developer asked for access in both cases. You can contact @allan directly if you want to give him the link to your page.I would make sure that you are loading jquery.js and datatables.js only once. I would look at using the latest versions of Datatables and FixedColumns. I would look for other references to
fixedcolumns
in your JS code. You usefixedColumns().update()
in yourdrawCallback
function. Should cause the issue but you could comment it out just to see. I tried it here and it seems fine:http://live.datatables.net/wifoyeja/3/edit
Kevin
Hi Kevin,
thank you for your suggestion.
fixedColumns().update() was my last release, got error with or without.
Monday for sure I'll have a test app, I'll write to you as soon as possible.
Send a message to Alan too... I'm waiting for an answer.
Hi Kevin,
I solve it!
On Datatable() I set only
"scrollY": "700px",
"scrollX": true
then after set fixedcolumn with new $.fn.dataTable.FixedColumns(table, {
leftColumns: 5
});
Now it works!