Borrar filtros
Borrar filtros

Retain uitable column width when .Data is updated

4 visualizaciones (últimos 30 días)
Knut Sindre Åbjørsbråten
Knut Sindre Åbjørsbråten el 5 de Jun. de 2018
Comentada: Sergey Miropolsky el 12 de Nov. de 2020
Hi. I have a uitable in a figure and load some data into it by setting .Data on the object. Sometimes the values will be changed after the table is created. If the user alters the column widths of the table to see the data better, these size changes gets reset when I update .Data (even if it's just single cell in the array).
I cannot obtain the real column width values using .ColumnWidth, so I cannot restore them. Is there another way?

Respuestas (1)

Rui Zou
Rui Zou el 28 de Jun. de 2018
Hi Knut,
I was able to reproduce the issue you are facing, and this is the designed behavior of uitable in figure. The ColumnWidth is what the user sets through the setter, i.e., calling "table.ColumnWidth = xxx". Dragging the column to resize it does not change the value of the ColumnWidth property.
However, depending on your use case, if you are able to change from figure to uifigure, this problem can be resolved. You can try it if this does not affect other UI widgets in your figure.
You can simply change "figure" to "uifigure" when you create it, and everything else should be the same.
For example
f = uifigure;
t = uitable(f, 'ColumnName',{'Name'; 'Telephone|Number'},'Data',{'Bob','555-1212'; 'Tom', '234-2342'});
  1 comentario
Sergey Miropolsky
Sergey Miropolsky el 12 de Nov. de 2020
Dear Rui,
The new Matlab uifigure and the corresponding GUI elements are extremely slow in comparison to the "traditional" figures, and thus are not practically usable for GUIs until this is fixed.
Is there a way to get the current column width for an old uitable after the user has resized it manually, perhaps by accessing the underlying java objects?
If yes, the user could read the actual column widths before .Data update, replace the .ColumnWidth array with the actual values, and first then update the .Data. The figure could then be expected to be redrawn correctly.

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by