How to close all expanded rows except current one in iView Tables

360 Views Asked by At

I am using iView Tables for loading data in table with expand option.

Currently row is expanding on click on expand button for the respective row and previously expanded is not collapsing, so I can see all expanded row.

Is it possible to collapse previously expanded rows and expand only current row.

iView Tables expanded link: https://www.iviewui.com/components/table-en#Expandable

1

There are 1 best solutions below

0
buqi On

use func toggleExpand to close the other rows,like this:

columns: [
    {
        type: 'expand',
        width: 50,
        render: (h, params) => {
            if (this.expandedId === params.row.id) {
                return h(expandRow, {
                    props: {
                        row: params.row
                    }
                })
            } else {
                 this.$refs.table.toggleExpand(params.index)
            }
        }
    }
]