Hidden columns in Datatable reappear on column sort and pagi


Topic: Hidden columns in Datatable reappear on column sort and pagination

scottwilliams pro premium priority asked 9 months ago

Maybe I'm just doing it wrong?

Expected behavior

Hidden columns in Datatable remain hidden regardless of column sorting or pagination changes.

Actual behavior

Columns reappear on column sorting and pagination changes but column headers remain hidden as expected.

Resources (screenshots, code snippets etc.)

Snippet: https://mdbootstrap.com/snippets/standard/kellyjromer/6004724


Grzegorz Bujański staff answered 9 months ago

Check this snippet: https://mdbootstrap.com/snippets/standard/grzegorz-bujanski/6009260#js-tab-view. It's look like datatableInstance.update(); in showColumns function is unnecessary and caused this issue


scottwilliams pro premium priority commented 9 months ago

Aw crap! That was an artifact from a previous solution that I missed removing. Thank you for the second set of eyes! :D It works perfectly.


Grzegorz Bujański staff answered 9 months ago

Datatable re-renders when you use sorting or pagination. But you can use render.mdb.datatable event and hide the columns when it is called.


scottwilliams pro premium priority commented 9 months ago

Yep. I tried that but when I do it runs away and loops until the browser freezes. Any thoughts on where I can put it to avoid the endless looping?


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 7.1.0
  • Device: Macbook Pro
  • Browser: Chrome
  • OS: MacOS Sonoma 14.3
  • Provided sample code: No
  • Provided link: Yes