niiknow / vue-datatables-net

Vue jQuery DataTables.net wrapper component
https://niiknow.github.io/vue-datatables-net/
MIT License
171 stars 58 forks source link

The table does not resize well #55

Closed enterlight closed 2 years ago

enterlight commented 3 years ago

First, thanks for your awesome work!!

Responsive or not, the table does not resize well. On creation it has a fixed width. I am using @table-created="setTableWidth()" to set the width to 100%, but I am sure there is a better way.

    setTableWidth() {
      this.$refs["table-files"].$refs.table.style.width = "100%"
    }

Is there a better way to set the

width to 100%?

noogen commented 3 years ago

This plugin is a wrapper of jQuery Datatables, which implement using table html component, and by nature, not very responsive. I've provide instruction on two ways that can be done here: https://github.com/niiknow/vue-datatables-net#responsive

In summary:

1. Using bootstrap framework, this plugin apply table-responsive class, which allow for horizontal scrolling when the table is too large to fit the screen.

2. jQuery Datatables can be set to responsive, which remove columns to fit screen size and using master-details (second row expand) to implement responsive. https://github.com/niiknow/vue-datatables-net/blob/master/example/responsive.png

Your issue can be done completely with CSS. Width in CSS is much easier to control than Height. Please check to make sure that all your container object have 100% width.

Also try:

.dataTables_wrapper table {
  width: 100%;
}
noogen commented 2 years ago

Stale issue.