How to position correctly a UITable into a figure (scrollbar disappeared)

2 visualizaciones (últimos 30 días)
Hi,
When I try to create this table the scrollbar disappears.
I need to load in this table approx data from a matrix of approx 200x8 cells and I'm trying to put it into a figure, but unfortunately as soon as I try to touch the position of the table, the scrollbar disappears and then I cannot scroll the table and the table columns names...
I've already had a look to the table properties but it seems there's no possibility to force enabling the table's scroller.
Thanks a lot for the help! :)
%% sample data creation
Strats_tab = strings(200,8);
Strats_tab(:,1) = deal("abcdefghilmnopqrstuvzabcdefghilmnopqrstuvz");
Strats_tab(:,2:5) = deal(datestr(today,'dd/mm/yyyy'));
Strats_tab(:,6:end) = deal(num2str(10^5,'%.0f'));
%% table+fig creation
strats_fig = figure('Position', [0 0 100 100]);
colnames = {'Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5', 'Column 6', 'Column 7', 'Column 8'};
settings_table = uitable(strats_fig, 'Data', cellstr(Strats_tab), 'ColumnName', colnames);
%set(settings_table,'ColumnWidth',{200,300});
table_extent = get(settings_table,'Extent');
set(settings_table,'Position',[0 0 table_extent(3) table_extent(4)+5],'RowStriping','on','FontSize',8,'RearrangeableColumns','on');
figure_size = get(strats_fig,'outerposition');
ssz = get(groot,'ScreenSize');
%desired_fig_size = [max(0,(ssz(3)-table_extent(3)+15)/2),max(0,(ssz(4)-table_extent(4)+65)/2), table_extent(3)+15,table_extent(4)+65]; %old
desired_fig_size = [figure_size(1) figure_size(2) table_extent(3)+15 table_extent(4)+65];
set(strats_fig,'outerposition', desired_fig_size);
strats_fig.MenuBar = 'none';
  2 comentarios
Mario Malic
Mario Malic el 25 de Feb. de 2021
I think figure doesn't support scrolling, only the uifigure.
endystrike
endystrike el 25 de Feb. de 2021
Hi Mario,
thanks for your answer. I don't think so: the scrolling bar works fine until I change the position of the table into the figure, but unfortunately I need to adjust the position but I cannot find the way to regulate it whitout losing the scrolling bar...
Can you help me please to set the position correctly? I'm referring to this line that makes troubles:
set(settings_table,'Position',[0 0 table_extent(3) table_extent(4)+5],'RowStriping','on','FontSize',8,'RearrangeableColumns','on');
Thanks a lot for your patience! :)

Iniciar sesión para comentar.

Respuesta aceptada

endystrike
endystrike el 25 de Feb. de 2021
fixed everything!
%table
strats_fig = figure('Name','Final Results','NumberTitle','off','Units','normalized','OuterPosition',[0,0,1,1]); clf;
settings_table = uitable(strats_fig,'Data',cellstr(Strats_tab), 'ColumnName', colnames,...
'Units','normalized','OuterPosition',[0,0,1,1],...
'RowStriping','on','FontSize',8,...
'RearrangeableColumns','on','ColumnWidth',num2cell(cw));
table_extent = get(settings_table,'Extent');
t_extra_margin = 0.05;
t_border = (1-table_extent(3)-t_extra_margin)/2;
%[0,0,min(1,table_extent(3))*1.05,min(1,table_extent(4))]; %ok left
desired_fig_size = [t_border, 0.1, min(1-t_border, table_extent(3)*(1+t_extra_margin)), min(.9,table_extent(4))]; %ok center
set(strats_fig,'outerposition', desired_fig_size);
strats_fig.MenuBar = 'none';

Más respuestas (0)

Categorías

Más información sobre Downloads en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by