Navigation

    Quasar Framework

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. olaf
    3. Best
    O
    • Profile
    • Following 0
    • Followers 0
    • Topics 9
    • Posts 21
    • Best 2
    • Groups 0

    Best posts made by olaf

    • How to scrollTo a row in a sorted table.

      Hi,

      I have got a table which can be sorted. I want to know how I can find the row index of a row after sorting so I can pass it to the scrollTo method.
      I have made a codepen sample to show the problem.
      Just run the sample and press the scroll to button.
      https://codepen.io/olafxso/pen/eYNydPR

      After that you will see it scrolls to row ‘15 jelly bean’. (it is know the last visible row in the table)

      Then sort the column Calories by clicking on the column header.
      The hit the button again. You will see it scrolls to row ‘51 Ice cream sandwhich’

      Well I would like to know how to scrollto row 15 after sorting a table column.

      Thanks for any idea’s!

      posted in Help
      O
      olaf
    • RE: How to scrollTo a row in a sorted table.

      Hi @cmanique ,

      Thanks for pointing me to the computedRows property. I changed it by using the array map prototype.
      This works well after filtering and sorting .

        scrollTo: function () {
            const index = this.$refs.table.computedRows.map(e => e.index).indexOf(15)
            this.$refs.table.scrollTo(index)
          }
      

      I am also pretty new with vue, quasar and javascript. So if any body has got some improvements, I would like to know it.

      posted in Help
      O
      olaf