필터 지우기
필터 지우기

UITable Scrollbars not showing and scrolling semi-INOP

조회 수: 4 (최근 30일)
Marc Elpel
Marc Elpel 2020년 2월 25일
댓글: Adam Danz 2020년 2월 25일
I have an app with UITable. During operation I import data to the table with ~350 rows. See image attached.
There is way more data than displayed, but the vertical scrollbar is not showing.
Sometimes I can use the scroll wheel to browse downward but it typically stops scrolling around 100-130 rows; I can never see the bottom of the data.
If I select a cell and use the down arrow it will walk down offscreen and back as if the table is fine... just not scrolling. Same for page down/up - the selected cell changes but scrolling does not follow.
The issue may be related to the creation code but I have yet to find the flaw... I've pasted the code below.
function handles = CreateTabbedPanels(handles)
%Create tab group
handles.tgroup = uitabgroup('Parent', handles.figure1,'TabLocation', 'top');
handles.tab1 = uitab('Parent', handles.tgroup, 'Title', 'Pressure Plots');
handles.tab2 = uitab('Parent', handles.tgroup, 'Title', 'Data Table');
%Place panels into each tab
handles.P1 = uipanel(handles.tab1);
handles.P2 = uipanel(handles.tab2);
%Reposition each panel to same location as panel 1
set(handles.P2,'position',get(handles.P1,'position'));
% Create Tab 1 items
handles.ax1 = subplot(1,1,1,'Parent',handles.P1);
% Create Tab 2 items - Create a data table
VarNames = {'Pressure','PumpEncoder','ZEncoder', ...
'ZEncValid', 'PressureSlope','SlopeFault','PressureFault'};
T = cell2table(cell(500,7), ...
'VariableNames', VarNames);
handles.uit1 = uitable('Data',T{:,:},'ColumnName',T.Properties.VariableNames,...
'Units', 'Normalized', 'ForegroundColor', [0,0,0], ...
'BackgroundColor',[0.9,0.9,0.9;0.82,0.82,0.82], ...
'FontSize', 10, ... %'FontWeight','bold', ...
'Position',[0, 0, 1, 1], ...
'Parent',handles.P2);
% Place in upper left
handles.uit1.Position = [0, 1-handles.uit1.Extent(4)-10, ...
handles.uit1.Extent(3)+10,handles.uit1.Extent(4)+10];
end

채택된 답변

Adam Danz
Adam Danz 2020년 2월 25일
편집: Adam Danz 2020년 2월 25일
The last line of your code is resizing the UITable and pushing the vertical scroll bar out of the figure boundaries.
When you create the UITable,
handles.uit1 = uitable('Data',T{:,:},'ColumnName',T.Properties.VariableNames,...
'Units', 'Normalized', 'ForegroundColor', [0,0,0], ...
'BackgroundColor',[0.9,0.9,0.9;0.82,0.82,0.82], ...
'FontSize', 10, ... %'FontWeight','bold', ...
'Position',[0, 0, 1, 1], ...
'Parent',handles.P2);
since the units are normalized and the position is [0 0 1 1] it is consuming the entire panel. This would result in the vertical scroll bar appearing along the right border of the panel.
But then the next line repositions the UITable.
handles.uit1.Position = [0, 1-handles.uit1.Extent(4)-10, ...
handles.uit1.Extent(3)+10,handles.uit1.Extent(4)+10];
What's your goal with that line? Note that extent is not a documented property of UITables.
  댓글 수: 2
Marc Elpel
Marc Elpel 2020년 2월 25일
Last line was a cut & paste frmo other code using tables where table size required a specific adjustment.
You were correct - comment that out and the scroll bars show, and I can now manually scroll to the bottom of data as well. Pretty simple - appreciate your feedback!
Adam Danz
Adam Danz 2020년 2월 25일
Glad I could help.
Whenever I use someone else's code I either look it over line-by-line to see what it's doing and I look up unfamiliar items, or I run it in debug mode line-by-line and examine the results of each line. If the code is very long I'll combine these approaches and quickly look over the lines and run the code in sections.
Avoid blindly running someone else's code.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by