ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.1k stars 14.64k forks source link

The expand row keys attribute of [bug report] El table can only control row expansion, not row closing, and can't be left blank #19701

Open liushangdev opened 4 years ago

liushangdev commented 4 years ago

Element UI version

2.13.2

OS/Browsers version

Windows7/Google Chrome 71.0.3578.98(正式版本) (64 位)

Vue version

2.6.11

Reproduction Link

https://codepen.io/liushangdev/pen/oNbZyNb

Steps to reproduce

通过监听行单击事件,点击未展开的行,可以展开,再次点击无法关闭,expand-row-keys已置为空

What is Expected?

可以通过单击事件 控制行展开,关闭

What is actually happening?

只能展开,不能关闭

element-bot commented 4 years ago

Translation of this issue:

Element UI version

2.13.2

OS/Browsers version

Windows 7 / Google Chrome 71.0.3578.98 (official version) (64 bit)

Vue version

2.6.11

Reproduction Link

https://codepen.io/liushangdev/pen/oNbZyNb

Steps to reproduce

By listening to the row click event, click the unexpanded row to expand it. Click again to close it. Expand row keys has been set to empty

What is Expected?

You can expand and close by clicking the event control line

What is actually happening?

Can only expand, can't close

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

fnlearner commented 3 years ago

逻辑应该在tree.js文件的getExpanded方法,在给expandRowKeys赋值为空的情况下,由于展开后旧值的expanded属性是true,所以就算included是false,所以getExpanded返回的结果也是true,就导致就算expandRowKeys为空,新值的expanded也是true

klren0312 commented 3 years ago

image

caiqichang commented 2 years ago

image

@klren0312 请问在只有row-key的情况下(如何通过row-key获取row?)如何调用此方法

klren0312 commented 2 years ago

image

@klren0312 请问在只有row-key的情况下(如何通过row-key获取row?)如何调用此方法

tableData.find(row => row[row-key] === row-key)