How to set fixed column widths in Q-Table
-
I’m trying to set fixed column widths in the column definition for a Q-Table.
For example:
1st column = 20px
2nd column = 20px
3rd column = 10px
4th column = 5px
ett.I read a couple of older posts that suggested adding style:‘width: NNpx’ in the columns definition in data. However that doesn’t work and I haven’t found any other solutions. Example:
template:
<q-table
class=“my-sticky-header-column-table”
table-class=“table-class”
:data=“filteredScores”
:columns=“columns”
virtual-scroll
hide-bottom
:pagination.sync=“pagination”
:rows-per-page-options="[0]"
row-key=“id”
:visible-columns=“visibleColumns”
/>columns: [ { name: 'last', required: true, label: 'Last Name', align: 'left', field: 'lastName', sortable: true, style: 'width: 20px' },
-
Hi @jrhopkins83 , have you been able to solve this problem?
-
By trial and error this seems to be working (let me know if not and I will revise this post): (It would be nice to have a few examples in Q-Table docs. It may be standard CSS but it is not always clear when CSS parameters apply and when they do not. Q-Table is a great display mechanism.)
style: “max-width: 500px; min-width: 500px” -
-
@metalsadman Thanks! Once again, careful reading of the docs can save a lot of time.