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

Table: add method resetFilter which can reset filter of a column #13176

Merged
merged 3 commits into from Nov 2, 2018

Conversation

elfman
Copy link
Contributor

@elfman elfman commented Oct 25, 2018

添加resetFilter方法,可以重置单列的filter

@element-bot
Copy link
Member

element-bot commented Oct 25, 2018

Deploy preview for element ready!

Built with commit bd71490

https://deploy-preview-13176--element.netlify.com

@ziyoung
Copy link
Contributor

ziyoung commented Oct 26, 2018

@elfman 我觉得 clearFilter 应该类似于 Form 组件的 clearValidate 方法。该方法支持参数,参数可以是字符串或者一个数组。
image

大佬再稍微调增一下代码吧。😂

@elfman
Copy link
Contributor Author

elfman commented Oct 26, 2018

@ziyoung 改为通过修改clearFilter来实现重置指定列的过滤器了,可以传入单个columnKey或由columnKey组成的数组,不传参时重置全部列

@ziyoung
Copy link
Contributor

ziyoung commented Oct 30, 2018

@elfman 有这么几个问题呀。

  1. 按照面这种方式调用代码会报错。
this.$refs.table.clearFilter(['el-table_1_column_4'])

utils 中 getColumnByKey 方法有些小问题。

  1. clearFilter 参数是 columnKey,这个不太好用。columnKey 是由 table 组件生成的。要调用这个方法还得知道是表格的第几个。调用 clearFilter 清除所有的 filter 还是合理的。😅

  2. Array.prototype.find 还是别使用了,至少 2.x 版本中别使用了.

  3. 要想解决 filter 的无法清除的问题,还要给 filter 起一个名字?

@elfman
Copy link
Contributor Author

elfman commented Oct 30, 2018

@ziyoung 你搞反了吧,columnKey是用户定义的,columnId才是组件生成的,所以我才用columnKey而不是columnId,你上面调用时传入的是columnId啊。
给filter起名字?你是指columnKey吗?我现在就是要通过columnKey来识别列啊,不然我想不出用什么特征来区别列了

@elfman
Copy link
Contributor Author

elfman commented Oct 30, 2018

@ziyoung 已经将find改过来了,在文档里增加了一个使用样例,你看下用法

<el-table
ref="filterTable"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也需要在例子中 script 部分添加 resetDateFilter 方法的。不然 jsffdle 上运行例子会出问题。

@ziyoung
Copy link
Contributor

ziyoung commented Oct 31, 2018

@elfman 文档再更新一下,补充个西班牙文档就可以合并了(不用翻译西班牙语)。

@elfman
Copy link
Contributor Author

elfman commented Oct 31, 2018

@ziyoung 我在我自己的电脑上运行时没出现这几个问题啊。倒是一直会固定出现下面的错误,重置到dev也还是会出现。
配置 Chrome 70.0.3538 (Mac OS X 10.14.0)

1) picker-options:firstDayOfWeek 1
     DatePicker
     Error: Uncaught AssertionError: expected '一\t' to equal '一' (/Users/luoxiongwen/Code/vue/element/node_modules/chai/chai.js:206)

2) picker-options:firstDayOfWeek 2
     DatePicker
     Error: Uncaught AssertionError: expected '二\t' to equal '二' (/Users/luoxiongwen/Code/vue/element/node_modules/chai/chai.js:206)

3) picker-options:firstDayOfWeek 3
     DatePicker
     Error: Uncaught AssertionError: expected '三\t' to equal '三' (/Users/luoxiongwen/Code/vue/element/node_modules/chai/chai.js:206)

4) picker-options:firstDayOfWeek 4
     DatePicker
     Error: Uncaught AssertionError: expected '四\t' to equal '四' (/Users/luoxiongwen/Code/vue/element/node_modules/chai/chai.js:206)

5) picker-options:firstDayOfWeek 5
     DatePicker
     Error: Uncaught AssertionError: expected '五\t' to equal '五' (/Users/luoxiongwen/Code/vue/element/node_modules/chai/chai.js:206)

6) picker-options:firstDayOfWeek 6
     DatePicker
     Error: Uncaught AssertionError: expected '六\t' to equal '六' (/Users/luoxiongwen/Code/vue/element/node_modules/chai/chai.js:206)

7) picker-options:firstDayOfWeek 7
     DatePicker
     Error: Uncaught AssertionError: expected '日\t' to equal '日' (/Users/luoxiongwen/Code/vue/element/node_modules/chai/chai.js:206)

@ziyoung
Copy link
Contributor

ziyoung commented Nov 2, 2018

@elfman 等下个版本时把依赖全更新一下就差不多了。有些测试用例经常出问题。🙈代码可以合并了。

话说 table 的属性也真是够多的,理清这么多属性都得花上一段时间。😂

@ziyoung ziyoung merged commit bcef4d9 into ElemeFE:dev Nov 2, 2018
@elfman elfman deleted the issue13126 branch November 2, 2018 10:31
weisiren168 pushed a commit to weisiren168/element that referenced this pull request Jun 20, 2019
)

* Table: clearFilter can clear the filters of specified columns

* optimize code and add resetFilter example in doc

* Table: Improve documentation of clearFilter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants