No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to make q-table max-width 100%

    Framework
    2
    6
    1849
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      walfin last edited by

      I’m trying to display a q-table but it is cut off on mobile (horizontal scrolling needed). How do I make it such that the max-width is 100%? table-style=“max-width:100% !important” doesn’t work.

      dobbel 1 Reply Last reply Reply Quote 0
      • dobbel
        dobbel @walfin last edited by

        @walfin

        If it’s possible: Using Q-Markup-Table instead of Q-table will be easier to style. Because markup table actually uses a native table.

        If you see a scrollbar then the content is wider than 100%. If you would succeed at setting the width of the q-table to 100% you’ll not see the entire table. Unless you implement rowspans, word break ect. That’s pretty easy to do in native tables but I have not seen anyone do this with Q-table.

        W 1 Reply Last reply Reply Quote 0
        • W
          walfin @dobbel last edited by walfin

          @dobbel I solved the problem by using a global style to override and set word-wrap and white-space to normal !important, as well as setting the inner q-table’s max-width to 100% !important.

          That said, I think this is a common enough use case that there should be an easier way to deal with this.

          dobbel 1 Reply Last reply Reply Quote 0
          • dobbel
            dobbel @walfin last edited by

            @walfin that’s great. Could you post the code?

            1 Reply Last reply Reply Quote 0
            • W
              walfin last edited by walfin

              @dobbel In app.styl:

              .screenwide
              	max-width 100% !important
              
              .screenwide .q-table
              	max-width 100% !important
              
              .screenwide td
              	white-space normal !important
              	word-wrap normal !important
              	hyphens manual
              
              .screenwide th
              	text-align center !important
              

              In the relevant template:

              <q-table :data="recipients" :columns="columns" :rows-per-page-options="[0]" selection="multiple" :selected.sync="selected" table-class="screenwide" dense>
              
              dobbel 1 Reply Last reply Reply Quote 1
              • dobbel
                dobbel @walfin last edited by dobbel

                @walfin

                thanks!

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post