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

    Export only filtered data in a q-table

    Help
    2
    3
    1155
    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.
    • L
      lesourcil last edited by

      Hi,

      I’m new in vue and im still learning. What I would like to do is use the export feature of a q-table but export only the filtered data instead of everything. Im using the fonction from the exemple but i don’t how to work/get only the filtered data.

      Any idea ?

          exportTable () {
            // naive encoding to csv format
            const content = [ this.columns.map(col => wrapCsvValue(col.label)) ].concat(
              this.data.map(row => this.columns.map(col => wrapCsvValue(
                typeof col.field === 'function'
                  ? col.field(row)
                  : row[col.field === void 0 ? col.name : col.field],
                col.format
              )).join(','))
            ).join('\r\n')
      

      Thx in advance.

      metalsadman 1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman @lesourcil last edited by metalsadman

        @lesourcil you can get the filtered rows by using a ref on your qtable and use filteredSortedRows computed prop, that’s the array you feed your exportTable function.

        So instead the line where it maps your data. Ie. this.data.map(... Use this.$refs.table.filteredSortedRows.map(....

        See the pen https://codepen.io/metalsadman/pen/LYNzrEE?editors=1010.

        1 Reply Last reply Reply Quote 1
        • L
          lesourcil last edited by

          @metalsadman You rock !

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