mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Use max column width when auto-sizing columns (#4394)
This commit is contained in:
@@ -9,7 +9,7 @@ export interface IAutoColumnSizeOptions extends Slick.PluginOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: IAutoColumnSizeOptions = {
|
const defaultOptions: IAutoColumnSizeOptions = {
|
||||||
maxWidth: 200,
|
maxWidth: 212,
|
||||||
autoSizeOnRender: false
|
autoSizeOnRender: false
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ export class AutoColumnSize<T> implements Slick.Plugin<T> {
|
|||||||
let template = this.getMaxTextTemplate(texts, columnDef, colIndex, data, rowEl);
|
let template = this.getMaxTextTemplate(texts, columnDef, colIndex, data, rowEl);
|
||||||
let width = this.getTemplateWidth(rowEl, template);
|
let width = this.getTemplateWidth(rowEl, template);
|
||||||
this.deleteRow(rowEl);
|
this.deleteRow(rowEl);
|
||||||
return width;
|
return width > this._options.maxWidth ? this._options.maxWidth : width;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTemplateWidth(rowEl: JQuery, template: JQuery | HTMLElement): number {
|
private getTemplateWidth(rowEl: JQuery, template: JQuery | HTMLElement): number {
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
};
|
};
|
||||||
}))
|
}))
|
||||||
};
|
};
|
||||||
self.plugins.push([rowNumberColumn, new AutoColumnSize(), new AdditionalKeyBindings()]);
|
self.plugins.push([rowNumberColumn, new AutoColumnSize({ maxWidth: this.configurationService.getValue<number>('resultsGrid.maxColumnWidth') }), new AdditionalKeyBindings()]);
|
||||||
self.dataSet = dataSet;
|
self.dataSet = dataSet;
|
||||||
|
|
||||||
// Create a dataSet to render without rows to reduce DOM size
|
// Create a dataSet to render without rows to reduce DOM size
|
||||||
|
|||||||
@@ -503,7 +503,7 @@ class GridTable<T> extends Disposable implements IView {
|
|||||||
this.table = this._register(new Table(tableContainer, { dataProvider: this.dataProvider, columns: this.columns }, tableOptions));
|
this.table = this._register(new Table(tableContainer, { dataProvider: this.dataProvider, columns: this.columns }, tableOptions));
|
||||||
this.table.setSelectionModel(this.selectionModel);
|
this.table.setSelectionModel(this.selectionModel);
|
||||||
this.table.registerPlugin(new MouseWheelSupport());
|
this.table.registerPlugin(new MouseWheelSupport());
|
||||||
this.table.registerPlugin(new AutoColumnSize({ autoSizeOnRender: !this.state.columnSizes && this.configurationService.getValue('resultsGrid.autoSizeColumns') }));
|
this.table.registerPlugin(new AutoColumnSize({ autoSizeOnRender: !this.state.columnSizes && this.configurationService.getValue('resultsGrid.autoSizeColumns'), maxWidth: this.configurationService.getValue<number>('resultsGrid.maxColumnWidth') }));
|
||||||
this.table.registerPlugin(copyHandler);
|
this.table.registerPlugin(copyHandler);
|
||||||
this.table.registerPlugin(this.rowNumberColumn);
|
this.table.registerPlugin(this.rowNumberColumn);
|
||||||
this.table.registerPlugin(new AdditionalKeyBindings());
|
this.table.registerPlugin(new AdditionalKeyBindings());
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ const resultsGridConfiguration: IConfigurationNode = {
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: true,
|
default: true,
|
||||||
description: nls.localize('autoSizeColumns', "Auto size the columns width on inital results. Could have performance problems with large number of columns or large cells")
|
description: nls.localize('autoSizeColumns', "Auto size the columns width on inital results. Could have performance problems with large number of columns or large cells")
|
||||||
|
},
|
||||||
|
'resultsGrid.maxColumnWidth': {
|
||||||
|
type: 'number',
|
||||||
|
default: 212,
|
||||||
|
description: nls.localize('maxColumnWidth', "The maximum width in pixels for auto-sized columns")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user