0

I have a table using DataTables and table data comes from a web service. If page width reduced, table column fixed but if refresh the page column data disappear or be secret.

How to fix the problem.

Pictures of the page can explain better.

Problematic column, after refresh and first load.

After F12 open and closed column fixed

UPDATE: First and Last column are fixed column and there is no scroll options.

  • 3
    Images are great, but even better is code with example data so that those with experience with the plugin can help. Please provide a [mre] in the question (do note the **minimal** -- try to remove columns/data/etc. until you've got the least amount of code that reproduces the issue). You can likely use [Stack Snippets](https://meta.stackoverflow.com/q/358992/215552) (icon looks like `<>`) to provide the example in the question. – Heretic Monkey Jun 01 '20 at 14:54
  • Does this answer your question? [datatable jquery - table header width not aligned with body width](https://stackoverflow.com/questions/17237812/datatable-jquery-table-header-width-not-aligned-with-body-width) – Dani Jun 01 '20 at 17:41
  • @Dani this comment not worked for me, first and last column are fixed column and the other column should be appear, but problem is last column which before fixed last column, are missing like above picture. – MERT METİN Jun 02 '20 at 10:50
  • @MERTMETİN `.columns.adjust()` doesn't work? – Dani Jun 02 '20 at 14:11
  • @Dani I put .DataTable().columns.adjust(); code piece after jquery my table id selector. And it worked for me. Critical point is after created table with datatable, i should insert the code. – MERT METİN Jun 03 '20 at 07:15
  • Do you have a modal? You have to use adjust in document ready or, if you have a modal, in `$('a[data-toggle="tab"]').on('shown.bs.tab', function(e){`. Try it and tell me – Dani Jun 03 '20 at 07:33
  • I solved my problem with below comment, so i did not use your code. Also there is no modal on my page @Dani – MERT METİN Jun 04 '20 at 07:01

1 Answers1

0

I put .DataTable().columns.adjust(); code piece after jquery my table id selector. And it worked for me. Critical point is after created table with datatable, i should insert the code

Also check below links to misalignment of columns

https://datatables.net/forums/discussion/46821/column-misalignment-only-at-first-time-or-reload