initializing datatable produces duplicate ids
initializing datatable produces duplicate ids
I'm using DataTables to use client side paging on an asp.net gridview.
I have a dop-down list which determines the data for the tables, when I change the value on the list I get the new gridview using ajax then replace the current gridview containers with the ones received in the ajax call then I initialize the datatables again.
the error occurs when the datatables are initialized, not when the gridview containers are replaced.
The duplicate ids are only in the header row.
any suggestions?
Replies
Without seeing what you are doing its hard to say what the issue is. Please post a link to your page or a test case showing the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I have a function that initializes the datatables -
a function that gets the new tables via an ajax call
a function that uses the data from the ajax call to replace the current tables with ones with updated data -
the RecreateDataTables function is called once at the beginning of document ready and is called every time the tables are replaces inside BindGVsSuccessCallback
Thanks for the code snippets. Its still unclear to me exactly what the problem is. Are you getting this error?
If so take a look at the link in the error for suggestions to fix:
https://datatables.net/manual/tech-notes/3
Kevin
I do not
the duplicate thread was because I realized I should post this as a question rather than a discussion... sorry
Are you saying that you are not getting the
Cannot reinitialise DataTable.
error?If you are not able to provide a link to your page or a test case then please provide more details of what the issue is. What duplicate IDs?
Kevin
yes I'm not getting the error, I am however getting a warning in the console saying I have duplicate element IDs for an element inside the header row of the table I turned into a datatable.
the warning message reads:
What is the checkbox
#SelectAllInGroupSwitch
? How how you creating it? Do you have the same checkbox on both tables? Maybe you need to remove and re-add it when recreating the table.This is not something Datatables is going to create. This would be much easier to help you find the problem with a link to your page or a simple test case replicating the issue.
Kevin
Hi @mishu666 ,
As Kevin said, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin