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: Option "entriesOptions" provided type "string" but expected type "array"

vnagornyy priority asked 3 years 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. https://mdbootstrap.com/snippets/standard/vnagornyy/3538589


Michał Duszak staff answered 3 years 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.

https://mdbootstrap.com/snippets/standard/m-duszak/3543260

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

vnagornyy priority commented 3 years 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. https://mdbootstrap.com/snippets/standard/vnagornyy/3545113

Is this a bug?


Michał Duszak staff commented 3 years ago

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


vnagornyy priority commented 3 years 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: https://imgur.com/a/B2dIQ7c


Michał Duszak staff commented 3 years 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: https://mdbootstrap.com/snippets/standard/m-duszak/3547425#html-tab-view https://mdbootstrap.com/snippets/standard/m-duszak/3547428#html-tab-view


Dae free commented 1 year 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 1 year ago

You need to pass this option via JS.

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


Dae free commented 1 year 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 1 year 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.

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 3.10.1
  • Device: PC
  • Browser: Chrome
  • OS: Win 10
  • Provided sample code: Yes
  • Provided link: Yes