dwqs / v2-table

A simple table component based Vue 2.x: https://dwqs.github.io/v2-table/
MIT License
100 stars 24 forks source link

v2-table scroll issue #11

Closed marcelaodev closed 6 years ago

marcelaodev commented 6 years ago

Hi there!

I'm facing a problem with table's scroll. The mentioned table is inside a b-modal (bootstrap vue) I'm using a fixed height enough to display 3 rows If I scroll all it down to see the 5#,6#,7# row and then switch to other modal containing <= 3 rows these 3 rows arent displayed. But i can scroll up back and see those rows

https://hastebin.com/zamuxovowo.xml

dwqs commented 6 years ago

Which version do you use? And can show me a case or more code? @marcelobcortes

marcelaodev commented 6 years ago

Hello! https://github.com/marcelobcortes/teste-fullstack

teste-fullstack/resources/assets/js/components/alunos.vue

(if you can I would love to receive feedback about the whole project code)

dwqs commented 6 years ago

@marcelobcortes I have seen your code and I want to know how to switch to other modal ?

marcelaodev commented 6 years ago

click in a entry in "alunos" sections. shows up "aluno" data and a v2-table. v2-table was configured to show 3 entries... so find a "aluno" with more than 3 entries (if you find easier, change alunocertificadofactory to create more entries) and scroll all it down and close after that, click in another entry and you will see that v2-table scroll's position did not get reseted despite of the data got refreshed

let me know if I still wasnt clear enough

dwqs commented 6 years ago

@marcelobcortes I have reproduced it. And I will fix it as soon as possible. Thanks for your feedback.

dwqs commented 6 years ago
<v2-table v-if="cursos.length>0" height=132 :data="cursos" ref="table">
    <v2-table-column width=20 label="#" prop="sequence"></v2-table-column>
    <v2-table-column label="Curso" prop="nome"></v2-table-column>
    <v2-table-column label="Data de matrícula" prop="datamatricula"></v2-table-column> 
    <v2-table-column label="Data de conclusão" prop="dataconclusao"></v2-table-column>  
    <v2-table-column label="Nota" prop="nota"></v2-table-column>  
</v2-table>

When cursos is updated, you can reset the scrollbar via calling updateScrollbar method of table:

this.cursos = new-cursos-data
this.$refs.table.updateScrollbar(true);

@marcelobcortes You need to upgrade v2-table to v3.0.1. Hope it helps you.

sknightq commented 6 years ago

@dwqs I think put the update scroll function in v2-table component rather than exposed outside because sometimes the table DOM's render doesn't finish, but I have invoked the update scroll function. like following snippets:

watch: {
  rows(newRows, oldRows) {
     this.$refs.table.updateScrollbar(true);
    // At this moment, my table is still old
  }
}