Effacer les filtres
Effacer les filtres

Setting UI table size to start from the top row and have a scroll bar

1 vue (au cours des 30 derniers jours)
Akshar Tandon
Akshar Tandon le 19 Jan 2018
Commenté : Greg le 19 Jan 2018
Hello I am trying to plot data in a table but when I set it to size automatically, I lose my scroll bar and hence the ability to see data on top of the figure. The only way for me to do that is to increase my window size, which in this case is unreasonable. I want the output of this function to be a figure where the first row of the table is at the top and there is a scroll wheel on the right hand side.
clear;
figfig = figure('Name','Final Results','NumberTitle','off');clf;
X = rand(150,9);
XCell = cellstr(string(X));
A(1:150,1:9) = string("#FFFFFF");
A = cellstr(A);
outHtml = strcat('<html><table border=0 width=400 bgcolor=', ...
A, ... % Choose the appropriate color for each cell
'"><TR><TD>', ...
XCell, ... % Convert num data to cell of chars
'</TD></TR></body></html>');
u = uitable(figfig,'Data',outHtml);
table_extent = get(u,'Extent');
figure_size = get(figfig,'outerposition');
desired_fig_size = [figure_size(1) figure_size(2) table_extent(3)+15 table_extent(4)+65];
set(u,'outerposition',[1 1 table_extent(3) table_extent(4)])
set(figfig,'outerposition', desired_fig_size);
end
  2 commentaires
Greg
Greg le 19 Jan 2018
A = string("#FFFFFF");
Is redundant. The double quotes give you a string.
A(1:150,1:9)
Is also unnecessary, as strcat will apply implicit expansion to a scalar input.

Connectez-vous pour commenter.

Réponse acceptée

Greg
Greg le 19 Jan 2018
Not sure why you're using HTML here...
u = uitable(figfig,'Data',outHtml,'Units','normalized','OuterPosition',[0,0,1,1]);
Then remove the other lines dealing with the uitable size/position.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by