Column index is getting changed

Column index is getting changed

vetridazeworksvetridazeworks Posts: 11Questions: 5Answers: 0

I am using datatable.js in visualforce page(Salesforce). So we show a lot of records in the page and we are using fixedheader js for freezing the headers. Also in the header sort click, I had overridden and make a call to my class to fetch latest data. The page has some inline editing also. So each time the data refreshes, the datatable is destroyed and re-initiated again.

So my problem is when I scroll down and edit a record, the page refreshes. When I scroll back to the top and click the header column, the index is showing wrong.

For eg: I have five columns in the table. After the inline edit, when I click the second column header it shows the index as 7 instead of 2

Any ideas?

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I'm not heard of this issue before I'm afraid. I'd need a link to a page showing the issue (either your own or on http://live.datatables.net ) showing the issue so I can debug it.

    Thanks,
    Allan

  • vetridazeworksvetridazeworks Posts: 11Questions: 5Answers: 0

    @allan I can't show the page because its within in salesforce, but what I can say is this is happening once the datatable is destroyed and re-initialized again. Can you tell me the order to do it?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I wonder if a different method might be better:

    The page has some inline editing also. So each time the data refreshes, the datatable is destroyed and re-initiated again.

    This sounds heavy handed. Why not just use cell().data() to update the data for the cell that was just edited?

    Allan

  • vetridazeworksvetridazeworks Posts: 11Questions: 5Answers: 0

    @allan Due to the complexity in the page, the cell.data is not used.. This is tightly handled and I am forced to destroy the page. The sort is overridden in the page. So whenever the header column is clicked it makes a call to backend to get refreshed data. The first time the header column index comes correctly, but once refreshed it shows the header in the multiples of the datatable refreshed.

    For eg: there are 16 columns in the table, the second time the table refreshes and if I want to sort the 2 column it shows the index as 19. If the fixed header is removed everything works perfectly. any idea?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Sounds like there might be an event leak somewhere. Can you use http://live.datatables.net or JSFiddle to create a replaceable test case so I can debug it?

    Allan

This discussion has been closed.