How to control Uitable scroller position?
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (2)
Jan
am 7 Feb. 2012
0 Stimmen
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 Kommentare
Matthew Worker
am 25 Apr. 2018
Hi yes, I have this issue and unable to solve it? In Matlab 2018a has there been a solution?
Walter Roberson
am 4 Jan. 2019
there was no change in r2018a or r2018b
Rueben Mendelsberg
am 25 Feb. 2020
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.
Kategorien
Mehr zu Platform and License finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!