필터 지우기
필터 지우기

No horizontal scrollbar on on UITable in App Designer

조회 수: 71 (최근 30일)
Russell Shomberg
Russell Shomberg 2022년 7월 13일
댓글: Arnab Samaddar-Chaudhuri 2023년 9월 15일
I am working on an app in AppDesigner. One of the features requires the ability to import a large table (CSV or XLSX) with an unknown size (~50-60 columns). The app starts with an empty table and the user selects one to view.
When the user imports the table, a vertical scrollbar is automatically generated and the user can scroll down all the rows. However, the horizontal scrollbar is not generated even though the table extends off the panel significantly. See attached image.
If I specify a size for the initial empty table then a horizontal scroll bar will appear, but it will not adjust to the correct size once the user imports a new table. Since the user table size is unknown, this will not work.
I only see this problem in the AppDesigner. Generate a UIFigure and UITable using the MATLAB command line, a scroll appears and adjusts to size without issue. However, this functionality is part of a larger app, and I would prefer to work inside the AppDesigner.
  댓글 수: 4
Staffan Neth
Staffan Neth 2022년 12월 5일
이동: Adam Danz 2022년 12월 6일
Still no official answer from Mathworks on this, or is there a bug report?
Adam Danz
Adam Danz 2022년 12월 7일
편집: Adam Danz 2022년 12월 7일
If you are experiencing this problem, it would be helpful to
  1. attach your app and any additional required files
  2. provide step-by-step instructions to recreate the problem starting with opening the app.
  3. tell us what MATLAB Release you're using (see the ver or version functions)
Alternatively, contact tech support to report a bug and provide the information above.

댓글을 달려면 로그인하십시오.

채택된 답변

Alexandre
Alexandre 2023년 3월 17일
편집: Alexandre 2023년 3월 17일
Thanks for reporting this bug!
Starting in MATLAB R2023a, AppDesigner does not experience this issue.
As an example under startupFcn in AppDesigner:
function startupFcn(app)
T = readtable("patients.xls");
app.UITable.Data = T;
end
You will now see that MATLAB properly includes a horizontal bar.
For earlier versions of MATLAB, please look at the clever workarounds below provided by our MATLAB Community.

추가 답변 (3개)

Arash Moshkforoush
Arash Moshkforoush 2022년 9월 28일
I had the same problem, but only when I tried using the app as a webapp.
What worked for me was that if I increase the number of columns to a large number in the ColumnName section of the UITable (in my case 20 columns; which is larger than the number of columns of the actual table), once a new table is loaded, the scrollbar is automatically generated.
Another possible workaround is to increase the ColumnWidth such that the initial table is wider than the alloted space.
Hope this helps
  댓글 수: 1
Staffan Neth
Staffan Neth 2022년 12월 5일
I tried you suggested workaround with ColumnWidth, and it made the scrollbar appear, but scrollbar is still not updated when the table is updated, so the scrollbar is still limited to the initial width, which is not enough.

댓글을 달려면 로그인하십시오.


Josh Kahn
Josh Kahn 2023년 2월 13일
Hi,
This is a known issue in R2022b. The suggested workaround for now is to reset the row names after adding data to your table:
% Add data to your table
app.UITable.Data = myData;
% Redraw the table and toggle the row names to numbered then back to blank.
drawnow;
app.UITable.RowName = 'numbered';
drawnow;
app.UITable.RowName = '';
Regards,
Josh

Mathijs Werkman
Mathijs Werkman 2023년 2월 13일
Hello, I had the same issue.
Affter a lot of trying got it to work by:
  • Create startupFcn
  • Creating a larger table at startupFcn: only changing columnnames is suficient.
tmp(1:1000) = {''};
app.UITable.ColumnName = tmp;
  • Before putting the actual data in the table, empty it first, and set RowName:
app.UITable.Data = [];
app.UITable.ColumnName = [];
drawnow;
app.UITable.RowName = ' '; % it has to be a character, cannot be empty ''
  • then update the table
app.UITable.Data = <your table data>;
app.UITable.ColumnName = <your columnnames>;
drawnow;

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by