// a given cell or all cells in a column.
@Input() cellClassCallback: (row: any, col: GridColumn) => string;
+ // comma-separated list of fields to show by default.
+ // This field takes precedence over hideFields.
+ // When a value is applied, any field not in this list will
+ // be hidden.
+ @Input() showFields: string;
+
// comma-separated list of fields to hide.
- // This is less verbose than having to define an <eg-grid-column/>
- // just to mark it hidden.
+ // This does not imply all other fields should be visible, only that
+ // the selected fields will be hidden.
@Input() hideFields: string;
// Allow the caller to jump directly to a specific page of
this.context.disableMultiSelect = this.disableMultiSelect === true;
this.context.rowFlairIsEnabled = this.rowFlairIsEnabled === true;
this.context.rowFlairCallback = this.rowFlairCallback;
+ if (this.showFields) {
+ this.context.defaultVisibleFields = this.showFields.split(',');
+ }
if (this.hideFields) {
this.context.defaultHiddenFields = this.hideFields.split(',');
}
stockVisible: string[];
idl: IdlService;
defaultHiddenFields: string[];
+ defaultVisibleFields: string[];
constructor(idl: IdlService, idlClass?: string) {
this.idl = idl;
applyColumnSettings(conf: GridColumnPersistConf[]) {
if (!conf || conf.length === 0) {
+ // No configuration is available, but we have a list of
+ // fields to show or hide by default
+
+ if (this.defaultVisibleFields) {
+ this.columns.forEach(col => {
+ if (this.defaultVisibleFields.includes(col.name)) {
+ col.visible = true;
+ } else {
+ col.visible = false;
+ }
+ });
- // If no configuration is available, but we have a list of
- // fields to hide by default, hide them.
- if (this.defaultHiddenFields) {
+ } else if (this.defaultHiddenFields) {
this.defaultHiddenFields.forEach(name => {
const col = this.getColByName(name);
if (col) {
rowFlairCallback: (row: any) => GridRowFlairEntry;
rowClassCallback: (row: any) => string;
cellClassCallback: (row: any, col: GridColumn) => string;
+ defaultVisibleFields: string[];
defaultHiddenFields: string[];
overflowCells: boolean;
this.columnSet.isSortable = this.isSortable === true;
this.columnSet.isMultiSortable = this.isMultiSortable === true;
this.columnSet.defaultHiddenFields = this.defaultHiddenFields;
+ this.columnSet.defaultVisibleFields = this.defaultVisibleFields;
this.generateColumns();
}