How to control Uitable scroller position?
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (2)
Jan
le 7 Fév 2012
0 votes
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 commentaires
Matthew Worker
le 25 Avr 2018
Hi yes, I have this issue and unable to solve it? In Matlab 2018a has there been a solution?
Walter Roberson
le 4 Jan 2019
there was no change in r2018a or r2018b
Rueben Mendelsberg
le 25 Fév 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.
Catégories
En savoir plus sur Platform and License dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!