Skip to content

Commit 77be67e

Browse files
ktriekazhukaudev
authored andcommitted
feat(table): add column width property, fix #134, fix #201 (#313)
1 parent 9065c52 commit 77be67e

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

src/app/pages/documentation/documentation.component.html

+8
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ <h3><a id="configuration" class="anchor" href="#configuration" aria-hidden="true
8080
Column class
8181
</td>
8282
</tr>
83+
<tr>
84+
<td>width</td>
85+
<td><span class="highlight">string</span></td>
86+
<td>''</td>
87+
<td>
88+
Column width, example: <span class="highlight">'20px'</span>, <span class="highlight">'20%'</span>
89+
</td>
90+
</tr>
8391
<tr>
8492
<td>editable</td>
8593
<td><span class="highlight">boolean</span></td>

src/app/shared/components/basic-example/basic-example.component.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ export class BasicExampleComponent {
1212
columns: {
1313
id: {
1414
title: 'ID',
15+
width: '60px',
1516
},
1617
name: {
1718
title: 'Full Name',
19+
width: '40%',
1820
},
1921
username: {
2022
title: 'User Name',

src/ng2-smart-table/components/thead/rows/thead-titles-row.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { Grid } from '../../../lib/grid';
1212
(click)="selectAllRows.emit($event)">
1313
</th>
1414
<th ng2-st-actions-title *ngIf="grid.showActionColumn('left')" [grid]="grid"></th>
15-
<th *ngFor="let column of grid.getColumns()" class="ng2-smart-th {{ column.id }}" [ngClass]="column.class">
15+
<th *ngFor="let column of grid.getColumns()" class="ng2-smart-th {{ column.id }}" [ngClass]="column.class"
16+
[style.width]="column.width" >
1617
<ng2-st-column-title [source]="source" [column]="column" (sort)="sort.emit($event)"></ng2-st-column-title>
1718
</th>
1819
<th ng2-st-actions-title *ngIf="grid.showActionColumn('right')" [grid]="grid"></th>

src/ng2-smart-table/lib/data-set/column.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export class Column {
55
title: string = '';
66
type: string = '';
77
class: string = '';
8+
width: string = '';
89
isSortable: boolean = false;
910
isEditable: boolean = true;
1011
isFilterable: boolean = false;
@@ -48,6 +49,7 @@ export class Column {
4849
protected process() {
4950
this.title = this.settings['title'];
5051
this.class = this.settings['class'];
52+
this.width = this.settings['width'];
5153
this.type = this.prepareType();
5254
this.editor = this.settings['editor'];
5355
this.filter = this.settings['filter'];

0 commit comments

Comments
 (0)