Topic: DataTable initialization crashes other components
uniagro premium asked 9 months ago
When setting a DataTable
component, if there are any other components they aren't rendered properly. For example, having a multiselect
with the data-mdb-select-init
attribute and a Datatable
with data-mdb-datatable-init
makes the Datatable works but not the select.
Expected behavior
Every element should be rendered properly.
Actual behavior
The only working element is the Datatable.
Resources (screenshots, code snippets etc.) https://mdbootstrap.com/snippets/standard/uniagro/5991162
Kamila Pieńkowska staff answered 9 months ago
It is a bug and we will fix it ass soon as possible. Until then add this code:
const select = document.querySelector('[data-mdb-select-init]')
const instance = mdb.Select.getOrCreateInstance(select)
uniagro premium commented 9 months ago
Thank you, as a workaround I'm creating the Datatable using Javascript.
Kamila Pieńkowska staff commented 9 months ago
It will work as well. Generally if any component is not initiating on pageload this solution would work.
Kamila Pieńkowska staff answered 9 months ago
Please publish your snippet otherwise I won't be able to see it.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Premium
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 7.1.0
- Device: Any
- Browser: Chrome
- OS: Windows/Android
- Provided sample code: Yes
- Provided link: Yes