Topic: Option "entriesOptions" provided type "string" but expected type "array"

vnagornyy priority asked 1 year ago

Expected behavior: data-mdb-entries-options="[25, 50, 100]" should work.

Actual behavior: It throws an error "Option "entriesOptions" provided type "string" but expected type "array"."

Resources (screenshots, code snippets etc.): Based on the documentation, this should work but it's reading data as a string instead of the data and throws an error.

Michał Duszak staff answered 1 year ago

Hello, thank you for your feedback. I will report this bug so it could be fixed in the nearest future. By the time we fix this you can pass this option via JS.

const datatableEl = document.querySelector('.datatable')
const datatable = mdb.Datatable.getInstance(datatableEl)
datatable.update({}, { entriesOptions: [25, 50, 100] })

vnagornyy priority commented 1 year ago

Thanks, @Michał Duszak. While testing this, I noticed that once you start changing "per page" dropdown the table gets a vertical scrollbar even though there is nothing to scroll. Here's a snippet with an example. Just change per page to 25 or 50 and hover over the table. You'll see scrollbar show up on hover.

Is this a bug?

Michał Duszak staff commented 1 year ago

I cannot replicate this bug. Could you provide a screenshot?

vnagornyy priority commented 1 year ago

This happens in Chrome and Firefox. The scrollbar shows up when scrolling and the mouse cursor is over the table. Here's a quick GIF of the issue:

Michał Duszak staff commented 1 year ago

Thank you for providing the GIF. It's strange, we will take a closer look at this case. For now i recommend setting the max-height if you want the datatable scroll to work properly, for example: data-mdb-max-height="920"

Or setting the display:none style for the inner datatable scrollbar, if you don't want any. Here are the snippets with this workaround:

Dae free commented 6 months ago

data-mdb-entries-options tag is still not working. Did you manage to solve it?

I am getting same error: provided type "string" but expected type "array"."

Kamila Pieńkowska staff commented 5 months ago

You need to pass this option via JS.

When this issue is resolved, it will be documented in the changelog.

Dae free commented 5 months ago

I have all this datatable designed in HTML, changing to JS i think it will not be an option. The issue was submited 1 year ago.

Kamila Pieńkowska staff commented 5 months ago

You don't need to change the whole implementation. You can still pass data via HTML. Initiating with JS and passing options on init will be enough.

Please insert min. 20 characters.


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



Specification of the issue

  • User: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.1
  • Device: PC
  • Browser: Chrome
  • OS: Win 10
  • Provided sample code: Yes
  • Provided link: Yes