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

scottwilliams priority asked 1 month 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 1 month 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 priority commented 1 month 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 1 month 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 priority commented 1 month 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

  • ForumUser: Priority
  • 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