Show currently selected record

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Show currently selected record

Postby roddy » Fri Nov 27, 2020 2:33 am

When using controller.setSelectedIndex(index); if the record selected is not shown on the form, the form doesn't scroll or move to show the selected record (the highlight just disappears off the screen).

I'm unable to find any method or property in the Controller, JSFoundset or JSForm to move the form to a selected record. Is there a property or method I am missing?
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am

Re: Show currently selected record

Postby swingman » Fri Nov 27, 2020 11:03 am

If you are using a framework there may different way to do this, but without a framework you can try:
Code: Select all
controller.showRecords(singleNumber_pk:Number)

Load data into the form and shows the form, is a shortcut for the functions 'loadRecords' and 'show'.
controller.showRecords(foundset);
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Show currently selected record

Postby Joas » Fri Nov 27, 2020 1:06 pm

From your post I assume you are using a data grid, is that correct?

To scroll the grid to the selected record, you can use the function scrollToSelection():
Code: Select all
elements.yourGrid.scrollToSelection();
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: Show currently selected record

Postby roddy » Tue Dec 01, 2020 1:08 am

The scrollToSelection() looks ideal. Thanks Joas.

I was a bit unsure on the showRecords() are I had already loaded in the records to the form, will read more into it swingman.

Really appreciate the feedback, it will make a huge difference to the operation of the app :)
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am

Re: Show currently selected record

Postby swingman » Tue Dec 01, 2020 11:45 am

If you have data in a grid, forget about my suggestion...
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Programming with Servoy

Who is online

Users browsing this forum: Google [Bot] and 10 guests