Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding row number column for QTable #6828

Closed
ryhn opened this issue Apr 15, 2020 · 9 comments
Closed

Adding row number column for QTable #6828

ryhn opened this issue Apr 15, 2020 · 9 comments
Assignees

Comments

@ryhn
Copy link

ryhn commented Apr 15, 2020

Hi,
How can I add row-number column to QTable.
No matter which column sorted, row-number column value must be 1 to data.length

Thanks.

@smolinari
Copy link
Collaborator

smolinari commented Apr 15, 2020

Hi,

In general, we'd rather have only bugs and suggestions as issues in the repos. So, please use either the forum or the discord channel for questions. You'll get answers there for sure. Please just have some patience.

And, if we come to the conclusion, your issue is a bug or a good suggestion, we'll ask you to then add an issue here.

Thanks. 😄

Scott

@ryhn
Copy link
Author

ryhn commented Apr 15, 2020

Hi,
There is no bug. But i think row-number column can be "feature request" that's why i wrote here.

i will take my chance on the quasar forum 😄

Thanks.

@smolinari
Copy link
Collaborator

smolinari commented Apr 15, 2020

I've changed my panned text for the future. See above. 😄

Scott

@pdanpdan pdanpdan self-assigned this Apr 15, 2020
@pdanpdan
Copy link
Collaborator

I'd like to think about this for some time - reopening for checking in the code.

@pdanpdan pdanpdan reopened this Apr 15, 2020
@rfox12
Copy link
Contributor

rfox12 commented Apr 18, 2020

@ryhn I think @pdanpdan has 3-4 full time jobs worth of work. ;)

This is my hack that perhaps does what you're looking for?
https://codepen.io/robert123789/pen/LYpZyaO

It uses CSS Counters, which I haven't tested much on different browsers/platforms. (I'm Chrome most of the time). Maybe this is a temp solution for you? Just trying to give back to the community.

In case the pen disappears here is the relevant code... for the <template>:

    <q-table
      :table-style="'counter-reset: cssRowCounter ' + ((pagination.page - 1) * pagination.rowsPerPage) + ';'"
      title="Treats"
      :data="data"
      :columns="columns"
      row-key="name"
      :pagination.sync="pagination"
    ><template v-slot:body-cell-row-number="props">
        <q-td><span class="rowNumber"/>
         </q-td>
      </template>
    </q-table>

And then all you need is an entry in the <style> area:

.rowNumber::before {
  counter-increment: cssRowCounter;
  content: counter(cssRowCounter) ". ";
}

And that's it!

@ryhn
Copy link
Author

ryhn commented Apr 18, 2020

Hi,

@rfox12 this is a good solution. I will try this. Thanks.

pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 19, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 19, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 19, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 20, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 21, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 22, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 22, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 23, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 23, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 24, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 24, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 24, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 24, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 24, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 25, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 25, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 25, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 25, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 26, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 26, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 27, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 28, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 28, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 28, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 28, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 28, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 28, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 29, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 29, 2020
pdanpdan added a commit to pdanpdan/quasar that referenced this issue Apr 29, 2020
rstoenescu pushed a commit that referenced this issue Apr 29, 2020
…s for item, body, body-cell and body-cell-[name] #6828 (#6850)
@rstoenescu
Copy link
Member

There's gonna be "rowIndex" and "pageIndex" in the sorted and filtered table available in "quasar" v1.10.0.

@hmeine
Copy link

hmeine commented Sep 28, 2020

I would have liked to make use of this to access the previous row in the data array, but apparently one does not have access to the sorted & filtered table data itself, right?

@rstoenescu
Copy link
Member

There's a computed prop on the QTable instance named filteredSortedRows -- you can use that @hmeine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants