mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-16 10:15:24 -06:00
Added option to provide maximum width of the column when 'Resize by data?’ option in the preferences is set to True. Fixes #6559
This commit is contained in:
parent
e095d382b3
commit
e68c8305a2
Binary file not shown.
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 160 KiB |
@ -374,6 +374,10 @@ Use the fields on the *Options* panel to manage editor preferences.
|
||||
Use the fields on the *Results grid* panel to specify your formatting
|
||||
preferences for copied data.
|
||||
|
||||
* Specify the maximum width of the column when 'Resize by data?' is set to True.
|
||||
If it is set to 0 then columns will auto-size to the maximum width of the data
|
||||
in the column. If 'Resize by data?' is set to False then this setting won't
|
||||
take any effect.
|
||||
* When the *Resize by data?* switch is set to *True*, then data columns will
|
||||
auto-size to the maximum width of the data in the column as loaded in the
|
||||
first batch. If False, the column will be sized to the widest of the data
|
||||
|
@ -10,6 +10,7 @@ New features
|
||||
************
|
||||
|
||||
| `Issue #3920 <https://redmine.postgresql.org/issues/3920>`_ - Do not block the query editor window when running a query.
|
||||
| `Issue #6559 <https://redmine.postgresql.org/issues/6559>`_ - Added option to provide maximum width of the column when 'Resize by data?’ option in the preferences is set to True.
|
||||
|
||||
Housekeeping
|
||||
************
|
||||
|
@ -39,7 +39,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function resizeAllColumns() {
|
||||
function resizeAllColumns(maxWidth) {
|
||||
var elHeaders = $container.find('.slick-header-column');
|
||||
var allColumns = grid.getColumns();
|
||||
elHeaders.each(function(index, el) {
|
||||
@ -53,6 +53,10 @@
|
||||
var colIndex = grid.getColumnIndex(columnDef.id);
|
||||
var column = allColumns[colIndex];
|
||||
var autoSizeWidth = Math.max(headerWidth, getMaxColumnTextWidth(columnDef, colIndex)) + 1;
|
||||
// If max width is provided and it is greater than 0
|
||||
if (typeof(maxWidth) !== 'undefined' && maxWidth > 0) {
|
||||
autoSizeWidth = Math.min(maxWidth, autoSizeWidth);
|
||||
}
|
||||
column.width = autoSizeWidth + (columnDef.addWidth || 0);
|
||||
});
|
||||
grid.setColumns(allColumns);
|
||||
|
@ -1189,7 +1189,7 @@ define('tools.querytool', [
|
||||
grid.render();
|
||||
// Resize all columns if column_data_auto_resize is true.
|
||||
if (self.preferences.column_data_auto_resize) {
|
||||
grid.resizeAllColumns && grid.resizeAllColumns();
|
||||
grid.resizeAllColumns && grid.resizeAllColumns(self.preferences.column_data_max_width);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -273,13 +273,26 @@ def register_query_tool_preferences(self):
|
||||
gettext("Resize by data?"), 'boolean', True,
|
||||
category_label=PREF_LABEL_RESULTS_GRID,
|
||||
help_str=gettext(
|
||||
'If set to True then data columns will auto-size to the maximum'
|
||||
'If set to True then data columns will auto-size to the maximum '
|
||||
'width of the data in the column as loaded in the first batch. If '
|
||||
'False, the column will be sized to the widest of the data type '
|
||||
'or column name.'
|
||||
)
|
||||
)
|
||||
|
||||
self.column_data_max_width = self.preference.register(
|
||||
'Results_grid', 'column_data_max_width',
|
||||
gettext("Maximum column width"), 'integer', 0,
|
||||
category_label=PREF_LABEL_RESULTS_GRID,
|
||||
help_str=gettext(
|
||||
'Specify the maximum width of the column when \'Resize by data?\' '
|
||||
'is set to True. If it is set to 0 then columns will auto-size to '
|
||||
'the maximum width of the data in the column. If '
|
||||
'\'Resize by data?\' is set to False then this setting won\'t '
|
||||
'take any effect.'
|
||||
)
|
||||
)
|
||||
|
||||
self.sql_font_size = self.preference.register(
|
||||
'Editor', 'sql_font_size',
|
||||
gettext("Font size"), 'numeric', '1',
|
||||
|
Loading…
Reference in New Issue
Block a user