Skip to content

Commit

Permalink
feat(grid): expose bool default template (#7823)
Browse files Browse the repository at this point in the history
* feat(grid): expose bool default template Closes #7224

* feat(grid-cell): exposing default template tick class

* style(grid): add styles for boolean column

* fix(grid-cell): change bool icon class

* fix(grid): move bool icon template otside the text wrapper

* fix(grid): move default template class on the host

* feat(grid): add missed underscore

* style(grid): add styles for the new template

* style(grid): move placeholder selector separately

* fix(grid): remove cell value interpolation space

* feat(grid): expose bool default template in hgrid cell

* chore(*): Changelog update

Co-authored-by: didimmova <d.dimova11@gmail.com>
Co-authored-by: Simeon Simeonoff <sim.simeonoff@gmail.com>
Co-authored-by: Zdravko Kolev <ZKolev@infragistics.com>
  • Loading branch information
4 people committed Jul 27, 2020
1 parent 49dfadd commit f8cdc44
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All notable changes for each version of this project will be documented in this
- **Breaking Changes** - The `igx-action-icon` has been renamed to `igx-navbar-action`. It should get renamed in your components via `ng update`;
- `igxGrid`
- Added `onScroll` event, which is emitted when the grid is scrolled vertically or horizontally.
- Each grid now expose a default handling for boolean column types. The column will display `check` or `close` icon, instead of true/false by default.
- `igxTreeGrid`
- Removed `onDataPreLoad` event as it is specific for remote virtualization implementation, which is not supported for the `igxTreeGrid`. A more generic `onScroll` event is exposed and can be used instead.
- `IgxTimePicker`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@
@extend %grid-cell--cross-selected !optional;
}

@include e(td, $m: bool) {
@extend %igx-grid__td--bool !optional;
}

@include e(td, $m: bool-true) {
@extend %igx-grid__td--bool-true !optional;
}

@include e(tr, $mods: (selected, filtered)) {
@extend %grid-row--selected--filtered !optional;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,23 @@
bottom: 0;
}

%igx-grid__td--bool {
justify-content: center;

igx-icon {
height: rem(18px);
width: rem(18px);
font-size: rem(18px);
color: igx-color($palette, 'grays', 500);
}
}

%igx-grid__td--bool-true {
igx-icon {
color: igx-color($palette, 'grays', 700);
}
}

%igx-grid__tr--edit {
border-bottom: 1px solid --var($theme, 'edit-mode-color');
position: relative;
Expand Down
10 changes: 9 additions & 1 deletion projects/igniteui-angular/src/lib/grids/cell.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
[row]="rowData"
[column]="this.column.field"
[containerClass]="'igx-grid__td-text'"
[metadata]="searchMetadata">{{ formatter ? (value | columnFormatter:formatter) : column.dataType === 'number' ? (value | igxdecimal:grid.locale) : column.dataType === 'date' ? (value | igxdate: grid.locale) : value }}</div>
[metadata]="searchMetadata">{{ formatter ? (value | columnFormatter:formatter) :
column.dataType === 'number' ?
(value | igxdecimal:grid.locale) :
column.dataType === 'date' ?
(value | igxdate: grid.locale) :
column.dataType === 'boolean' ? "" :
value
}}</div>
<igx-icon *ngIf="column.dataType === 'boolean'">{{value ? 'check' : 'close'}}</igx-icon>
</ng-template>
<ng-template #inlineEditor let-cell="cell">
<ng-container *ngIf="column.dataType === 'string'">
Expand Down
5 changes: 5 additions & 0 deletions projects/igniteui-angular/src/lib/grids/cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
return this.editMode || this.cellTemplate ? '' : this.value;
}

@HostBinding('class.igx-grid__td--bool-true')
public get booleanClass() {
return this.column.dataType === 'boolean' && this.value;
}

/**
* Returns a reference to the nativeElement of the cell.
* ```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
[attr.aria-describedby]="gridID + '_' + col.field | igxStringReplace:'.':'_'"
[class.igx-grid__td--pinned]="col.pinned"
[class.igx-grid__td--number]="col.dataType === 'number'"
[class.igx-grid__td--bool]="col.dataType === 'boolean'"
[ngClass]="col.cellClasses | igxCellStyleClasses:rowData[col.field]:rowData:col.field:viewIndex:grid.pipeTrigger"
[ngStyle]="col.cellStyles | igxCellStyles:rowData[col.field]:rowData:col.field:viewIndex:grid.pipeTrigger"
[editMode]="col.editable && crudService.isInEditMode(index, col.index)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
[class.igx-grid__td--edited]="rowID | transactionState:col.field:grid.rowEditable:grid.transactions:grid.pipeTrigger"
[attr.aria-describedby]="gridID + '_' + col.field | igxStringReplace:'.':'_'"
[class.igx-grid__td--number]="col.dataType === 'number'"
[class.igx-grid__td--bool]="col.dataType === 'boolean'"
[ngClass]="col.cellClasses | igxCellStyleClasses:rowData[col.field]:rowData:col.field:viewIndex:grid.pipeTrigger"
[ngStyle]="col.cellStyles | igxCellStyles:rowData[col.field]:rowData:col.field:viewIndex:grid.pipeTrigger"
[editMode]="col.editable && crudService.isInEditMode(index, col.index)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
[row]="rowData"
[column]="this.column.field"
[containerClass]="'igx-grid__td-text'"
[metadata]="searchMetadata">{{ formatter ? (value | columnFormatter:formatter) : column.dataType === 'number' ? (value | igxdecimal:grid.locale) : column.dataType === 'date' ? (value | igxdate: grid.locale) : value }}</div>
[metadata]="searchMetadata">{{ formatter ? (value | columnFormatter:formatter) :
column.dataType === 'number' ?
(value | igxdecimal:grid.locale) :
column.dataType === 'date' ?
(value | igxdate: grid.locale) :
column.dataType === 'boolean' ? "" :
value
}}</div>
<igx-icon *ngIf="column.dataType === 'boolean'">{{value ? 'check' : 'close'}}</igx-icon>
</ng-template>
<ng-template #inlineEditor let-cell="cell">
<ng-container *ngIf="column.dataType === 'string'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
[class.igx-grid__td--edited]="rowID | transactionState:col.field:grid.rowEditable:grid.transactions:grid.pipeTrigger"
[attr.aria-describedby]="gridID + '_' + col.field | igxStringReplace:'.':'_'"
[class.igx-grid__td--number]="col.dataType === 'number'"
[class.igx-grid__td--bool]="col.dataType === 'boolean'"
[ngClass]="col.cellClasses | igxCellStyleClasses:rowData[col.field]:rowData:col.field:viewIndex:grid.pipeTrigger"
[ngStyle]="col.cellStyles | igxCellStyles:rowData[col.field]:rowData:col.field:viewIndex:grid.pipeTrigger"
[editMode]="col.editable && crudService.isInEditMode(index, col.index)"
Expand Down

0 comments on commit f8cdc44

Please sign in to comment.