Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: DataTable not updating hidden column on close

darrenh65 premium asked 4 years ago


I have a mdbEditor on a page that displays only a few of the columns in a table. The edit modal displays all the fields in the table. When the modal closes on a save operation I expect all the fields to be updated in the underlying table whether they are visible or not.

What happens though is that hidden columns, using 'visible: false' in the column definition do not get updated. This means if the edit button is pressed again the original value is displayed for those fields.

I have created a snippet that hides the 'Examples' column. If this field is updated in the edit modal and then the modal is opened a second time the change is not displayed: https://mdbootstrap.com/snippets/jquery/darrenh65/2815254


Marcin Luczak staff answered 4 years ago


Hi,

Field with visible: false is not updated with the modal because it is not rendered into DOM, thus it cannot be changed with modal because there is no place new values could be saved. Knowing that your desired invisible elements are in the last column you can reach that functionality with setting display: none via CSS selectors:

#ex1 th:last-of-type {
    display: none;  
}
#ex1 tr td:last-of-type {
    display: none;  
}

Please see this code working inside my snippet: https://mdbootstrap.com/snippets/jquery/marcin-luczak/2816043

Regards, Marcin


darrenh65 premium commented 4 years ago

Yep that works, I was unaware of those selectors, thanks Marcin

regards, Darren


Marcin Luczak staff commented 4 years ago

I'm happy that I could help.

Regards, Marcin



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Resolved

Specification of the issue

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB jQuery
  • MDB Version: 4.19.1
  • Device: PC
  • Browser: Chrome/Firefox
  • OS: Win10/Linux
  • Provided sample code: No
  • Provided link: Yes