diff --git a/src/components/dropdown/nz-dropdown.component.ts b/src/components/dropdown/nz-dropdown.component.ts
index 79d1ccb57d1..2ebb8647eeb 100644
--- a/src/components/dropdown/nz-dropdown.component.ts
+++ b/src/components/dropdown/nz-dropdown.component.ts
@@ -26,13 +26,13 @@ import { ConnectionPositionPair } from '../core/overlay';
export type NzPlacement = 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'topLeft' | 'topCenter' | 'topRight';
@Component({
- selector : 'nz-dropdown',
- encapsulation: ViewEncapsulation.None,
- animations : [
+ selector : 'nz-dropdown',
+ encapsulation : ViewEncapsulation.None,
+ animations : [
DropDownAnimation
],
changeDetection: ChangeDetectionStrategy.OnPush,
- template : `
+ template : `
@@ -53,16 +53,21 @@ export type NzPlacement = 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'topLe
(mouseleave)="_onMouseLeaveEvent($event)"
[style.minWidth.px]="_triggerWidth"
(click)="_clickDropDown($event)">
-
+
+
+
+
+
`,
- styleUrls : [
+ styleUrls : [
'./style/index.less',
'./style/patch.less'
]
})
export class NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit {
+ hasFilterButton = false;
_triggerWidth = 0;
_placement: NzPlacement = 'bottomLeft';
_dropDownPosition: 'top' | 'bottom' = 'bottom';
@@ -143,7 +148,9 @@ export class NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit {
}
ngOnInit() {
- this._nzMenu.setDropDown(true);
+ if (this._nzMenu) {
+ this._nzMenu.setDropDown(true);
+ }
}
ngOnDestroy() {
@@ -180,7 +187,7 @@ export class NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit {
mouse$,
this.nzVisibleChange.asObservable()
)
- , 300);
+ , 300);
this._startSubscribe(observable$);
}
diff --git a/src/components/dropdown/nz-dropdown.directive.ts b/src/components/dropdown/nz-dropdown.directive.ts
index 56dde1da3bf..59c8ec265d2 100644
--- a/src/components/dropdown/nz-dropdown.directive.ts
+++ b/src/components/dropdown/nz-dropdown.directive.ts
@@ -1,8 +1,10 @@
-import { Directive, ElementRef } from '@angular/core';
+import { Directive, ElementRef, HostBinding } from '@angular/core';
+
@Directive({
selector: '[nz-dropdown]',
})
export class NzDropDownDirective {
+ @HostBinding('class.ant-dropdown-trigger') _dropDownTrigger = true;
constructor(public elementRef: ElementRef) {
}
}
diff --git a/src/components/menu/nz-menu-item.component.ts b/src/components/menu/nz-menu-item.component.ts
index 6e9b3e29456..374c5036314 100644
--- a/src/components/menu/nz-menu-item.component.ts
+++ b/src/components/menu/nz-menu-item.component.ts
@@ -31,9 +31,9 @@ export class NzMenuItemComponent implements AfterViewInit {
set nzSelected(value: boolean) {
this.selected = value;
if (value) {
- this._renderer.addClass(this.hostElement.nativeElement, 'ant-menu-item-selected')
+ this._renderer.addClass(this.hostElement.nativeElement, this.isInDropDown ? 'ant-dropdown-menu-item-selected' : 'ant-menu-item-selected')
} else {
- this._renderer.removeClass(this.hostElement.nativeElement, 'ant-menu-item-selected')
+ this._renderer.removeClass(this.hostElement.nativeElement, this.isInDropDown ? 'ant-dropdown-menu-item-selected' : 'ant-menu-item-selected')
}
}
diff --git a/src/components/table/nz-table-filter.component.ts b/src/components/table/nz-table-filter.component.ts
new file mode 100644
index 00000000000..11c6691e993
--- /dev/null
+++ b/src/components/table/nz-table-filter.component.ts
@@ -0,0 +1,33 @@
+import {
+ Component,
+ HostBinding, OnInit
+} from '@angular/core';
+import { NzDropDownComponent } from '../dropdown/nz-dropdown.component';
+
+@Component({
+ selector: '[nz-table-filter]',
+ template: `
+
+
+
+
+
+
+ `
+})
+export class NzTableFilterComponent implements OnInit {
+ @HostBinding('class.ant-table-filter-dropdown-btns') _dropDownButton = true;
+
+ hideDropDown() {
+ this.nzDropDownComponent.nzVisible = false;
+ this.nzDropDownComponent._hide();
+ }
+
+ constructor(private nzDropDownComponent: NzDropDownComponent) {
+ }
+
+ ngOnInit() {
+ this.nzDropDownComponent.hasFilterButton = true;
+ this.nzDropDownComponent.nzClickHide = false;
+ }
+}
diff --git a/src/components/table/nz-table.component.ts b/src/components/table/nz-table.component.ts
index e6d7583d6a3..4c2c56f68f1 100644
--- a/src/components/table/nz-table.component.ts
+++ b/src/components/table/nz-table.component.ts
@@ -5,8 +5,12 @@ import {
ElementRef,
AfterViewInit,
EventEmitter,
- Output
+ Output,
+ ContentChild,
+ ChangeDetectorRef,
+ TemplateRef, OnInit
} from '@angular/core';
+import { measureScrollbar } from '../util/mesureScrollBar';
@Component({
selector : 'nz-table',
@@ -19,6 +23,8 @@ import {
+
-
`,
styleUrls : [
@@ -64,16 +83,19 @@ import {
'./style/patch.less'
]
})
-export class NzTableComponent implements AfterViewInit {
+export class NzTableComponent implements AfterViewInit, OnInit {
/** public data for ngFor tr */
data = [];
+ _scroll;
_el: HTMLElement;
+ _headerBottomStyle;
_current = 1;
_total: number;
_pageSize = 10;
_dataSet = [];
_isInit = false;
_isAjax = false;
+ ths = [];
@Output() nzPageSizeChange: EventEmitter = new EventEmitter();
@Output() nzPageIndexChange: EventEmitter = new EventEmitter();
@Output() nzDataChange: EventEmitter = new EventEmitter();
@@ -88,6 +110,17 @@ export class NzTableComponent implements AfterViewInit {
@Input() nzShowTotal = false;
@Input() nzShowFooter = false;
@Input() nzShowTitle = false;
+ @ContentChild('nzFixedHeader') fixedHeader: TemplateRef;
+
+ @Input()
+ set nzScroll(value) {
+ this._scroll = value;
+ this._cd.detectChanges();
+ }
+
+ get nzScroll() {
+ return this._scroll;
+ }
/** async data */
@Input()
@@ -172,7 +205,15 @@ export class NzTableComponent implements AfterViewInit {
}
}
- constructor(private _elementRef: ElementRef) {
+ ngOnInit() {
+ const scrollbarWidth = measureScrollbar();
+ this._headerBottomStyle = {
+ marginBottom : `-${scrollbarWidth}px`,
+ paddingBottom: `0px`
+ }
+ }
+
+ constructor(private _elementRef: ElementRef, private _cd: ChangeDetectorRef) {
this._el = this._elementRef.nativeElement;
}
diff --git a/src/components/table/nz-table.module.ts b/src/components/table/nz-table.module.ts
index 562ac5b10a0..d3a9effe8df 100644
--- a/src/components/table/nz-table.module.ts
+++ b/src/components/table/nz-table.module.ts
@@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
import { NzTableComponent } from './nz-table.component';
import { NzThDirective } from './nz-th.directive';
import { NzTdDirective } from './nz-td.directive';
+import { NzTableFilterComponent } from './nz-table-filter.component';
import { NzTheadDirective } from './nz-thead.directive';
import { NzTbodyDirective } from './nz-tbody.directive';
import { NzTbodyTrDirective } from './nz-tbody-tr.directive';
@@ -13,8 +14,8 @@ import { NzPaginationModule } from '../pagination/nz-pagination.module';
import { CommonModule } from '@angular/common';
@NgModule({
- declarations: [ NzTableComponent, NzThDirective, NzTdDirective, NzTheadDirective, NzTbodyDirective, NzTbodyTrDirective, NzTableDividerDirective, NzTableSortComponent ],
- exports : [ NzTableComponent, NzThDirective, NzTdDirective, NzTheadDirective, NzTbodyDirective, NzTbodyTrDirective, NzTableDividerDirective, NzTableSortComponent ],
+ declarations: [ NzTableFilterComponent, NzTableComponent, NzThDirective, NzTdDirective, NzTheadDirective, NzTbodyDirective, NzTbodyTrDirective, NzTableDividerDirective, NzTableSortComponent ],
+ exports : [ NzTableFilterComponent, NzTableComponent, NzThDirective, NzTdDirective, NzTheadDirective, NzTbodyDirective, NzTbodyTrDirective, NzTableDividerDirective, NzTableSortComponent ],
imports : [ CommonModule, NzPaginationModule, NzSpinModule ]
})
diff --git a/src/components/table/nz-th.directive.ts b/src/components/table/nz-th.directive.ts
index ea4780fec96..39372e3ebab 100644
--- a/src/components/table/nz-th.directive.ts
+++ b/src/components/table/nz-th.directive.ts
@@ -2,17 +2,30 @@ import {
Directive,
Input,
HostBinding,
- ElementRef
+ ElementRef, OnInit, OnDestroy
} from '@angular/core';
+import { NzTableComponent } from './nz-table.component';
@Directive({
selector: '[nz-th]'
})
-export class NzThDirective {
+export class NzThDirective implements OnInit, OnDestroy {
_el: HTMLElement;
+ @Input() nzWidth;
@Input() @HostBinding(`class.ant-table-selection-column`) nzCheckbox;
- constructor(private _elementRef: ElementRef) {
+ constructor(private _elementRef: ElementRef, private nzTableComponent: NzTableComponent) {
this._el = this._elementRef.nativeElement;
}
+
+ ngOnInit() {
+ this.nzTableComponent.ths.push(this);
+ }
+
+ ngOnDestroy() {
+ const index = this.nzTableComponent.ths.indexOf(this);
+ if (index > -1) {
+ this.nzTableComponent.ths.splice(index, 1);
+ }
+ }
}
diff --git a/src/components/util/mesureScrollBar.ts b/src/components/util/mesureScrollBar.ts
new file mode 100644
index 00000000000..3bafcc1c795
--- /dev/null
+++ b/src/components/util/mesureScrollBar.ts
@@ -0,0 +1,30 @@
+let scrollbarWidth;
+
+// Measure scrollbar width for padding body during modal show/hide
+const scrollbarMeasure = {
+ position: 'absolute',
+ top: '-9999px',
+ width: '50px',
+ height: '50px',
+ overflow: 'scroll',
+};
+
+export function measureScrollbar() {
+ if (typeof document === 'undefined' || typeof window === 'undefined') {
+ return 0;
+ }
+ if (scrollbarWidth) {
+ return scrollbarWidth;
+ }
+ const scrollDiv = document.createElement('div');
+ for (const scrollProp in scrollbarMeasure) {
+ if (scrollbarMeasure.hasOwnProperty(scrollProp)) {
+ scrollDiv.style[scrollProp] = scrollbarMeasure[scrollProp];
+ }
+ }
+ document.body.appendChild(scrollDiv);
+ const width = scrollDiv.offsetWidth - scrollDiv.clientWidth;
+ document.body.removeChild(scrollDiv);
+ scrollbarWidth = width;
+ return scrollbarWidth;
+}
diff --git a/src/showcase/app.module.ts b/src/showcase/app.module.ts
index a1f26071a9e..bbe3e022b35 100644
--- a/src/showcase/app.module.ts
+++ b/src/showcase/app.module.ts
@@ -2,7 +2,7 @@ import { BrowserModule, Title } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
-import { HttpModule } from '@angular/http';
+import { HttpClientModule } from '@angular/common/http';
import { RouterModule, PreloadAllModules } from '@angular/router';
import { routes } from './app.routing.module';
import { AppComponent } from './app.component';
@@ -18,7 +18,7 @@ import { NzHighlightModule } from './share/nz-highlight/nz-highlight.module';
BrowserModule,
BrowserAnimationsModule,
FormsModule,
- HttpModule,
+ HttpClientModule,
NgZorroAntdModule.forRoot({ extraFontName: 'anticon', extraFontUrl: './assets/fonts/iconfont' }),
NzCodeBoxModule,
NzHighlightModule,
diff --git a/src/showcase/nz-demo-dropdown/nz-demo-dropdown.html b/src/showcase/nz-demo-dropdown/nz-demo-dropdown.html
index 1311bd21835..6e3c393a939 100644
--- a/src/showcase/nz-demo-dropdown/nz-demo-dropdown.html
+++ b/src/showcase/nz-demo-dropdown/nz-demo-dropdown.html
@@ -2,7 +2,6 @@
Dropdown 下拉菜单
向下弹出的列表。
何时使用
-
当页面上的操作命令过多时,用此组件可以收纳操作元素。点击或移入触点,会出现一个下拉菜单。可在列表中进行选择,并执行相应的命令。
@@ -90,6 +89,12 @@ nz-dropdown
Directive |
- |
+
+ [nz-dropdown-custom] |
+ 自定义下拉菜单内容,不可与menu混用 |
+ ng-content |
+ - |
+
nzTrigger |
触发下拉的行为 |
diff --git a/src/showcase/nz-demo-table/nz-demo-table-ajax.component.ts b/src/showcase/nz-demo-table/nz-demo-table-ajax.component.ts
index 5452fac35cd..46da5931e29 100644
--- a/src/showcase/nz-demo-table/nz-demo-table-ajax.component.ts
+++ b/src/showcase/nz-demo-table/nz-demo-table-ajax.component.ts
@@ -11,13 +11,32 @@ import { RandomUserService } from './randomUser.service';
[nzLoading]="_loading"
[nzTotal]="_total"
[(nzPageIndex)]="_current"
- (nzPageIndexChange)="_refreshData()"
+ (nzPageIndexChange)="refreshData()"
[(nzPageSize)]="_pageSize"
- (nzPageSizeChange)="_refreshData()">
+ (nzPageSizeChange)="refreshData(true)">
- Name |
- Age |
+
+ Name
+
+ |
+
+ Age
+
+
+
+ -
+
+
+
+
+ OK
+ Reset
+
+
+ |
Email |
@@ -39,13 +58,34 @@ export class NzDemoTableAjaxComponent implements OnInit {
_total = 1;
_dataSet = [];
_loading = true;
+ _sortValue = null;
+ _filterGender = [
+ { name: 'male', value: false },
+ { name: 'female', value: false }
+ ];
+
+ sort(value) {
+ this._sortValue = value;
+ this.refreshData();
+ }
+
+ reset() {
+ this._filterGender.forEach(item => {
+ item.value = false;
+ });
+ this.refreshData(true);
+ }
constructor(private _randomUser: RandomUserService) {
}
- _refreshData = () => {
+ refreshData(reset = false) {
+ if (reset) {
+ this._current = 1;
+ }
this._loading = true;
- this._randomUser.getUsers(this._current, this._pageSize).subscribe((data: any) => {
+ const selectedGender = this._filterGender.filter(item => item.value).map(item => item.name);
+ this._randomUser.getUsers(this._current, this._pageSize, 'name', this._sortValue, selectedGender).subscribe((data: any) => {
this._loading = false;
this._total = 200;
this._dataSet = data.results;
@@ -53,7 +93,7 @@ export class NzDemoTableAjaxComponent implements OnInit {
};
ngOnInit() {
- this._refreshData();
+ this.refreshData();
}
}
diff --git a/src/showcase/nz-demo-table/nz-demo-table-colspan-rowspan.component.ts b/src/showcase/nz-demo-table/nz-demo-table-colspan-rowspan.component.ts
new file mode 100644
index 00000000000..4b68dbd6231
--- /dev/null
+++ b/src/showcase/nz-demo-table/nz-demo-table-colspan-rowspan.component.ts
@@ -0,0 +1,73 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'nz-demo-table-colspan-rowspan',
+ template: `
+
+
+
+ Name |
+ Age |
+ Home phone |
+ Address |
+
+
+
+
+
+ {{data.name}}
+ |
+ {{data.age}} |
+ {{data.tel}} |
+ {{data.phone}} |
+ {{data.address}} |
+
+
+ `,
+ styles : []
+})
+export class NzDemoTableColspanRowspanComponent implements OnInit {
+ data = [ {
+ key : '1',
+ name : 'John Brown',
+ age : 32,
+ tel : '0571-22098909',
+ phone : 18889898989,
+ address: 'New York No. 1 Lake Park',
+ }, {
+ key : '2',
+ name : 'Jim Green',
+ tel : '0571-22098333',
+ phone : 18889898888,
+ age : 42,
+ address: 'London No. 1 Lake Park',
+ }, {
+ key : '3',
+ name : 'Joe Black',
+ age : 32,
+ tel : '0575-22098909',
+ phone : 18900010002,
+ address: 'Sidney No. 1 Lake Park',
+ }, {
+ key : '4',
+ name : 'Jim Red',
+ age : 18,
+ tel : '0575-22098909',
+ phone : 18900010002,
+ address: 'London No. 2 Lake Park',
+ }, {
+ key : '5',
+ name : 'Jake White',
+ age : 18,
+ tel : '0575-22098909',
+ phone : 18900010002,
+ address: 'Dublin No. 2 Lake Park',
+ } ];
+
+ constructor() {
+ }
+
+ ngOnInit() {
+ }
+}
+
diff --git a/src/showcase/nz-demo-table/nz-demo-table-custom-filter.component.ts b/src/showcase/nz-demo-table/nz-demo-table-custom-filter.component.ts
new file mode 100644
index 00000000000..c2da33d6f46
--- /dev/null
+++ b/src/showcase/nz-demo-table/nz-demo-table-custom-filter.component.ts
@@ -0,0 +1,149 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'nz-demo-table-custom-filter',
+ template: `
+
+
+
+
+ Name
+
+
+
+
+
+
+
+ |
+
+ Age
+ |
+
+ Address
+
+
+
+ -
+
+
+
+
+ OK
+ Reset
+
+
+ |
+
+
+
+
+
+ {{data.name}}
+ |
+ {{data.age}} |
+ {{data.address}} |
+
+
+ `,
+ styles : [
+ `
+ .custom-filter-dropdown {
+ padding: 8px;
+ border-radius: 6px;
+ background: #fff;
+ box-shadow: 0 1px 6px rgba(0, 0, 0, .2);
+ }
+
+ .custom-filter-dropdown ::ng-deep nz-input {
+ width: 130px;
+ margin-right: 8px;
+ }
+
+ .highlight {
+ color: #f50;
+ }
+ `
+ ]
+})
+export class NzDemoTableCustomFilterComponent implements OnInit {
+ searchValue = '';
+ filterAddressArray = [
+ { name: 'London', value: false },
+ { name: 'Sidney', value: false }
+ ];
+ sortMap = {
+ name : null,
+ age : null,
+ address: null
+ };
+ sortName = null;
+ sortValue = null;
+ data = [
+ {
+ name : 'John Brown',
+ age : 32,
+ address: 'New York No. 1 Lake Park',
+ }, {
+ name : 'Jim Green',
+ age : 42,
+ address: 'London No. 1 Lake Park',
+ }, {
+ name : 'Joe Black',
+ age : 32,
+ address: 'Sidney No. 1 Lake Park',
+ }, {
+ name : 'Jim Red',
+ age : 32,
+ address: 'London No. 2 Lake Park',
+ }
+ ];
+ copyData = [ ...this.data ];
+
+ sort(sortName, value) {
+ this.sortName = sortName;
+ this.sortValue = value;
+ Object.keys(this.sortMap).forEach(key => {
+ if (key !== sortName) {
+ this.sortMap[ key ] = null;
+ } else {
+ this.sortMap[ key ] = value;
+ }
+ });
+ this.search();
+ }
+
+ search() {
+ const searchAddress = this.filterAddressArray.filter(address => address.value);
+ const filterFunc = (item) => {
+ return (searchAddress.length ? searchAddress.some(address => item.address.indexOf(address.name) !== -1) : true) &&
+ (item.name.indexOf(this.searchValue) !== -1)
+ };
+ this.data = [ ...this.copyData.filter(item => filterFunc(item)) ];
+ this.data = [ ...this.data.sort((a, b) => {
+ if (a[ this.sortName ] > b[ this.sortName ]) {
+ return (this.sortValue === 'ascend') ? 1 : -1;
+ } else if (a[ this.sortName ] < b[ this.sortName ]) {
+ return (this.sortValue === 'ascend') ? -1 : 1;
+ } else {
+ return 0;
+ }
+ }) ];
+ }
+
+ reset(array) {
+ array.forEach(item => {
+ item.value = false;
+ });
+ this.search();
+ }
+
+ constructor() {
+ }
+
+ ngOnInit() {
+ }
+}
+
diff --git a/src/showcase/nz-demo-table/nz-demo-table-edit.component.ts b/src/showcase/nz-demo-table/nz-demo-table-edit.component.ts
new file mode 100644
index 00000000000..31e497f1b30
--- /dev/null
+++ b/src/showcase/nz-demo-table/nz-demo-table-edit.component.ts
@@ -0,0 +1,83 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'nz-demo-table-edit',
+ template: `
+
+
+
+ name |
+ age |
+ address |
+ action |
+
+
+
+
+
+ {{data.name}}
+
+
+
+ |
+
+ {{data.age}}
+
+
+
+ |
+ {{data.address}} |
+
+
+ Edit
+
+
+ Save
+
+
+ Cancel
+
+
+ |
+
+
+ `,
+ styles : []
+})
+export class NzDemoTableEditComponent implements OnInit {
+ editRow = null;
+ tempEditObject = {};
+ data = [
+ {
+ key : 0,
+ name : 'Edward King 0',
+ age : 32,
+ address: 'London, Park Lane no. 0',
+ }
+ ];
+
+ edit(data) {
+ this.tempEditObject[ data.key ] = { ...data };
+ this.editRow = data.key;
+ }
+
+ save(data) {
+ Object.assign(data, this.tempEditObject[ data.key ]);
+ this.editRow = null;
+ }
+
+ cancel(data) {
+ this.tempEditObject[ data.key ] = {};
+ this.editRow = null;
+ }
+
+ constructor() {
+ }
+
+ ngOnInit() {
+ this.data.forEach(item => {
+ this.tempEditObject[ item.key ] = {};
+ })
+ }
+}
+
diff --git a/src/showcase/nz-demo-table/nz-demo-table-fixed-header.component.ts b/src/showcase/nz-demo-table/nz-demo-table-fixed-header.component.ts
new file mode 100644
index 00000000000..f5b1702c957
--- /dev/null
+++ b/src/showcase/nz-demo-table/nz-demo-table-fixed-header.component.ts
@@ -0,0 +1,42 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'nz-demo-table-fixed-header',
+ template: `
+
+
+
+
+ Name |
+ Age |
+ Address |
+
+
+
+
+
+ {{data.name}} |
+ {{data.age}} |
+ {{data.address}} |
+
+
+ `,
+ styles : []
+})
+export class NzDemoTableFixedHeaderComponent implements OnInit {
+ data = [];
+
+ constructor() {
+ }
+
+ ngOnInit() {
+ for (let i = 0; i < 100; i++) {
+ this.data.push({
+ name : `Edward King ${i}`,
+ age : 32,
+ address: `London, Park Lane no. ${i}`,
+ });
+ }
+ }
+}
+
diff --git a/src/showcase/nz-demo-table/nz-demo-table-reset-filter.component.ts b/src/showcase/nz-demo-table/nz-demo-table-reset-filter.component.ts
new file mode 100644
index 00000000000..a3d27519ca0
--- /dev/null
+++ b/src/showcase/nz-demo-table/nz-demo-table-reset-filter.component.ts
@@ -0,0 +1,160 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'nz-demo-table-reset-filter',
+ template: `
+
+
+
+
+
+
+
+
+
+ Name
+
+
+
+
+ -
+
+
+
+
+ OK
+ Reset
+
+
+ |
+
+ Age
+
+ |
+
+ Address
+
+
+
+
+ -
+
+
+
+
+ OK
+ Reset
+
+
+ |
+
+
+
+
+
+ {{data.name}}
+ |
+ {{data.age}} |
+ {{data.address}} |
+
+
+ `,
+ styles : [
+ `
+ .table-operations {
+ margin-bottom: 16px;
+ }
+
+ .table-operations > button {
+ margin-right: 8px;
+ }
+ `
+ ]
+})
+export class NzDemoTableResetFilterComponent implements OnInit {
+ filterNameArray = [
+ { name: 'Joe', value: false },
+ { name: 'Jim', value: false },
+ ];
+ filterAddressArray = [
+ { name: 'London', value: false },
+ { name: 'Sidney', value: false }
+ ];
+ sortMap = {
+ name : null,
+ age : null,
+ address: null
+ };
+ sortName = null;
+ sortValue = null;
+ data = [
+ {
+ name : 'John Brown',
+ age : 32,
+ address: 'New York No. 1 Lake Park',
+ }, {
+ name : 'Jim Green',
+ age : 42,
+ address: 'London No. 1 Lake Park',
+ }, {
+ name : 'Joe Black',
+ age : 32,
+ address: 'Sidney No. 1 Lake Park',
+ }, {
+ name : 'Jim Red',
+ age : 32,
+ address: 'London No. 2 Lake Park',
+ }
+ ];
+ copyData = [ ...this.data ];
+
+ sort(sortName, value) {
+ this.sortName = sortName;
+ this.sortValue = value;
+ Object.keys(this.sortMap).forEach(key => {
+ if (key !== sortName) {
+ this.sortMap[ key ] = null;
+ } else {
+ this.sortMap[ key ] = value;
+ }
+ });
+ this.search();
+ }
+
+ search() {
+ const searchAddress = this.filterAddressArray.filter(address => address.value);
+ const searchName = this.filterNameArray.filter(name => name.value);
+ const filterFunc = (item) => {
+ return (searchAddress.length ? searchAddress.some(address => item.address.indexOf(address.name) !== -1) : true) &&
+ (searchName.length ? searchName.some(name => item.name.indexOf(name.name) !== -1) : true)
+ };
+ this.data = [ ...this.copyData.filter(item => filterFunc(item)) ];
+ this.data = [ ...this.data.sort((a, b) => {
+ if (a[ this.sortName ] > b[ this.sortName ]) {
+ return (this.sortValue === 'ascend') ? 1 : -1;
+ } else if (a[ this.sortName ] < b[ this.sortName ]) {
+ return (this.sortValue === 'ascend') ? -1 : 1;
+ } else {
+ return 0;
+ }
+ }) ];
+ }
+
+ reset(array) {
+ array.forEach(item => {
+ item.value = false;
+ });
+ this.search();
+ }
+
+ constructor() {
+ }
+
+ ngOnInit() {
+ }
+}
+
diff --git a/src/showcase/nz-demo-table/nz-demo-table-size.component.ts b/src/showcase/nz-demo-table/nz-demo-table-size.component.ts
index 3785162ee50..ca8ac878274 100644
--- a/src/showcase/nz-demo-table/nz-demo-table-size.component.ts
+++ b/src/showcase/nz-demo-table/nz-demo-table-size.component.ts
@@ -53,6 +53,14 @@ import { Component, OnInit } from '@angular/core';
+
+
+
+
+
+
+
+
@@ -75,6 +83,7 @@ import { Component, OnInit } from '@angular/core';
Here is Title
-
-
- Name |
- Age |
- Address |
- Action |
-
-
+
+
+
+ Name |
+ Age |
+ Address |
+ Action |
+
+
+
{{data.name}} |
@@ -130,6 +141,7 @@ import { Component, OnInit } from '@angular/core';
.components-table-demo-control-bar {
margin-bottom: 10px;
}
+
.components-table-demo-control-bar ::ng-deep .ant-form-item {
margin-right: 16px;
margin-bottom: 8px;
@@ -139,12 +151,13 @@ import { Component, OnInit } from '@angular/core';
})
export class NzDemoTableSizeComponent implements OnInit {
_dataSet = [];
- _bordered = false;
+ _bordered = true;
_loading = false;
_pagination = true;
_header = true;
_title = true;
_footer = true;
+ _fixHeader = false;
_size = 'small';
constructor() {
diff --git a/src/showcase/nz-demo-table/nz-demo-table-sort.component.ts b/src/showcase/nz-demo-table/nz-demo-table-sort.component.ts
deleted file mode 100644
index c1212ebcc24..00000000000
--- a/src/showcase/nz-demo-table/nz-demo-table-sort.component.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-
-@Component({
- selector: 'nz-demo-table-sort',
- template: `
-
-
-
-
-
- Name
-
- |
-
-
- Age
-
-
- |
- Address |
-
-
-
-
-
- {{data.name}}
- |
- {{data.age}} |
- {{data.address}} |
-
-
- `,
- styles : []
-})
-export class NzDemoTableSortComponent implements OnInit {
- ageSort = 'false';
- data = [ {
- key : '1',
- name : 'John Brown',
- age : 32,
- address: 'New York No. 1 Lake Park',
- }, {
- key : '2',
- name : 'Jim Green',
- age : 42,
- address: 'London No. 1 Lake Park',
- }, {
- key : '3',
- name : 'Joe Black',
- age : 32,
- address: 'Sidney No. 1 Lake Park',
- } ];
-
- ageSortChange($event) {
- if ($event === 'ascend') {
- this.data = [ ...this.data.sort((a, b) => {
- return a.age - b.age;
- }) ];
- } else if ($event === 'descend') {
- this.data = [ ...this.data.sort((a, b) => {
- return b.age - a.age;
- }) ];
- }
- }
-
- constructor() {
- }
-
- ngOnInit() {
- }
-}
-
diff --git a/src/showcase/nz-demo-table/nz-demo-table.component.ts b/src/showcase/nz-demo-table/nz-demo-table.component.ts
index 86fff23f3c5..74b437b2d60 100644
--- a/src/showcase/nz-demo-table/nz-demo-table.component.ts
+++ b/src/showcase/nz-demo-table/nz-demo-table.component.ts
@@ -10,7 +10,11 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core';
})
export class NzDemoTableComponent implements OnInit {
NzDemoTableBasicCode = require('!!raw-loader!./nz-demo-table-basic.component');
- NzDemoTableSortCode = require('!!raw-loader!./nz-demo-table-sort.component');
+ NzDemoTableEditCode = require('!!raw-loader!./nz-demo-table-edit.component');
+ NzDemoTableFixedHeaderCode = require('!!raw-loader!./nz-demo-table-fixed-header.component');
+ NzDemoTableColspanRowspanCode = require('!!raw-loader!./nz-demo-table-colspan-rowspan.component');
+ NzDemoTableResetFilterCode = require('!!raw-loader!./nz-demo-table-reset-filter.component');
+ NzDemoTableCustomFilterCode = require('!!raw-loader!./nz-demo-table-custom-filter.component');
NzDemoTableSelectionCode = require('!!raw-loader!./nz-demo-table-selection.component');
NzDemoTableSelectionAndOperationCode = require('!!raw-loader!./nz-demo-table-selection-and-operation.component');
NzDemoTableSelectionPropsCode = require('!!raw-loader!./nz-demo-table-selection-props.component');
diff --git a/src/showcase/nz-demo-table/nz-demo-table.html b/src/showcase/nz-demo-table/nz-demo-table.html
index 70227170f9a..a12474aa882 100644
--- a/src/showcase/nz-demo-table/nz-demo-table.html
+++ b/src/showcase/nz-demo-table/nz-demo-table.html
@@ -4,7 +4,6 @@
Table 表格
展示行列数据。
何时使用
-
当有大量结构化的数据需要展现时;
@@ -22,12 +21,6 @@ 代码演示简单的表格,最后一列是各种操作。
-
-
-
-
@@ -46,6 +39,20 @@
代码演示配置选择框的默认属性。
+
+
+
+
使用受控属性对筛选和排序状态进行控制。
+
nzTable可以像HTML table 标签一样自定义表头和内容,通过配合 nz-table-sort
与 nz-table-filter
可以方便的自定义筛选和排序功能。
+
+
+
+
+
+
通过 nz-dropdown
的 nz-dropdown-custom
属性自定义筛选菜单
+
nzTable可以像HTML table 标签一样自定义表头和内容。
+
+
@@ -61,6 +68,25 @@
代码演示
+
+
+
+
+
+
+
+
+