How to control Uitable scroller position?
显示 更早的评论
Hi,
when an uitable is updated, uitable automatically resets to focus on the top row of data.
Is there a way to set the scroll position in the table instead of "jumping" every time the table is updated?
Thankyou for your time...
Regards, Sainath M.
采纳的回答
更多回答(2 个)
Jan
2012-2-7
0 个投票
You can use Yair's FEX: findjobj to get the Java handle of the table. Then there are all possibilities y programmer can need.
Please ask the technical support for this problem also. The more users ask for improvements of the currently very weakly supported UITAB, UITABLE and UITREE, the more like is an update.
2 个评论
Matthew Worker
2018-4-25
Hi yes, I have this issue and unable to solve it? In Matlab 2018a has there been a solution?
Walter Roberson
2019-1-4
there was no change in r2018a or r2018b
Rueben Mendelsberg
2020-2-25
The answer provided by Can is pretty close but doesn't bring the table back to exactly where the focus was before you started. It just makes whatever row you interacted with one up from the bottom.
Also, there seems to be the need to throw a drawnow() command before resetting the uitable scroll position.
To get back to the exact view you started from you need to insert at the beginning of the SelectionChangeCallback or the CellEditCallback:
function callbackFcn(src,evt)
jscrollpane = javaObjectEDT(findjobj(src));
viewport = javaObjectEDT(jscrollpane.getViewport);
P = viewport.getViewPosition();
jtable = = javaObjectEDT( viewport.getView );
% Do whatever you need to do in the callback...
%
%
drawnow() %This is necessary to ensure the view position is set after matlab hijacks it
viewport.setViewPosition(P);
end
The table will flicker as matlab forces it back to the start and java pulls it back to where it was, but that is the cleanest implementation that is made more efficient if the gui is written as a handle class.
类别
在 帮助中心 和 File Exchange 中查找有关 Platform and License 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!