From 12bcf7bd14d0ca8f098ff7ad293e4f0f2fd8f872 Mon Sep 17 00:00:00 2001 From: H <21418592@qq.com> Date: Thu, 6 Apr 2017 17:07:03 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20remoteFilter=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E6=94=AF=E6=8C=81=E7=94=A8=E6=88=B7=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E7=AD=9B=E9=80=89=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/routers/table.vue | 40 +++++++++++++++++++++++++++++++++- src/components/table/table.vue | 8 +++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/examples/routers/table.vue b/examples/routers/table.vue index bed307ce..7eb7eee3 100644 --- a/examples/routers/table.vue +++ b/examples/routers/table.vue @@ -15,7 +15,28 @@ }, { title: '年龄', - key: 'age' + key: 'age', + filters:[ + { + label: '小学', + value: '小学' + }, + { + label: '中学', + value: '大学' + }, + { + label: '中学', + value: '中学' + } + ], + filterRemote:function(value,key,column){ + var that = this; + this.$Notice.open({title:`正在远程过滤${key}`,desc:value,duration:3,onClose:function(){ + that.remoteFilter(value,key,column) + }}) + + } }, { title: '地址', @@ -45,6 +66,23 @@ } ] } + + }, + methods:{ + remoteFilter:function(val,age,column){ + this.data1 = [ + { + name: '模拟1', + age: 18, + address: '北京市朝阳区芍药居' + }, + { + name: '模拟2', + age: 25, + address: '北京市海淀区西二旗' + }, + ] + } } } diff --git a/src/components/table/table.vue b/src/components/table/table.vue index 1b588c1a..dbc2cd1c 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -496,6 +496,9 @@ }, filterData (data, column) { return data.filter((row) => { + if(typeof column.filterRemote == 'function'){ //如果定义了远程过滤方法则忽略此方法 + return true; + } let status = !column._filterChecked.length; for (let i = 0; i < column._filterChecked.length; i++) { status = column.filterMethod(column._filterChecked[i], row); @@ -505,6 +508,11 @@ }); }, filterOtherData (data, index) { + let column = this.cloneColumns[index]; + if(typeof column.filterRemote == 'function'){ + column.filterRemote.call(this.currentContext,column._filterChecked,column.key,column); + } + this.cloneColumns.forEach((col, colIndex) => { if (colIndex !== index) { data = this.filterData(data, col); From acc6c4a64e7db3386e24c4c5e30e2515d1867037 Mon Sep 17 00:00:00 2001 From: H <21418592@qq.com> Date: Fri, 7 Apr 2017 12:01:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?filterRemotec.call(this.$parent,value,key,c?= =?UTF-8?q?olumn)=20=E6=8A=8Atable=E5=AF=B9=E8=B1=A1=E4=BC=A0=E7=BB=99filt?= =?UTF-8?q?erRemote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/table/table.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/table/table.vue b/src/components/table/table.vue index dbc2cd1c..4df61334 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -510,7 +510,7 @@ filterOtherData (data, index) { let column = this.cloneColumns[index]; if(typeof column.filterRemote == 'function'){ - column.filterRemote.call(this.currentContext,column._filterChecked,column.key,column); + column.filterRemote.call(this.$parent,column._filterChecked,column.key,column); } this.cloneColumns.forEach((col, colIndex) => {