IgxTreeGrid Conditional Cell Styling
The IgxTreeGrid component in Ignite UI for Angular provides conditional styling of cells based on custom rules.
This can be achieved by setting the IgxColumnComponent
input cellClasses
to an object literal containing key-value pairs. The key is the name of the CSS class, while the value is either a callback function that returns a boolean, or boolean value. The result is a convenient material styling of the cell.
데모
개요
IgxColumnComponent
cellClasses
입력을 설정하고 사용자 규칙을 정의하여 IgxTreeGrid 셀의 조건부 스타일을 지정할 수 있습니다.
<!-- sample.component.html -->
<igx-column field="UnitPrice" header="Unit Price" [dataType]="'number'" [cellClasses] = "priceClasses">
<ng-template igxCell let-cell="cell" let-val>
<span *ngIf="cell.row.data.UnitPrice == 0">-</span>
<span *ngIf="cell.row.data.UnitPrice != 0">${{val}}</span>
</ng-template>
</igx-column>
cellClasses
입력은 키 값 쌍을 포함하는 객체 리터럴을 허용하며 여기서 키는 CSS 클래스의 이름이고 값은 불 또는 불 값을 반환하는 콜백 함수입니다.
// sample.component.ts
private upPriceCondition = (rowData: any, columnKey: any): boolean => {
return rowData[columnKey] > 25;
}
private downPriceCondition = (rowData: any, columnKey: any): boolean => {
return rowData[columnKey] <= 25;
}
public priceClasses = {
downPrice: this.downPriceCondition,
upPrice: this.upPriceCondition
};
// sample.component.scss
::ng-deep {
.upPrice {
color: red;
}
.downPrice {
color: green;
}
}
::ng-deep 또는 **ViewEncapsulation.None
**을 사용하여 사용자 스타일을 현재 컴포넌트와 그 하위 요소를 통해 강제로 적용할 수 있습니다.
API 참조
추가 리소스
커뮤니티는 활동적이고 새로운 아이디어를 항상 환영합니다.
View page on
GitHub