Table view record selected or not

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Table view record selected or not

Postby hardina09 » Tue Jul 17, 2012 4:38 pm

In my form I need to validate that user has selected record or not in table view (locked).
Table view is loaded with SQL, when we say foundset.getSelectedIndex() gives 1st record in table view even if record is not selected. How to check whether user has selected record or not in tableview.
hardina09
 
Posts: 62
Joined: Tue Apr 24, 2012 9:46 pm

Re: Table view record selected or not

Postby ROCLASI » Tue Jul 17, 2012 7:26 pm

Hi,

In Servoy when a form (any type) has a foundset with records then at least 1 record is already selected. So foundset.getSelectedIndex() always gives a positive value back.
Only when there are no records in the foundset the value will be 0.

What are you trying to accomplish exactly ?
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5205
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Table view record selected or not

Postby hardina09 » Tue Jul 17, 2012 7:42 pm

I am working on a form that display data in table view. Need to check that user has selected record and hits button. Is there any way where we can check that user has selected record ortherwise prompt them to select record in table view.
hardina09
 
Posts: 62
Joined: Tue Apr 24, 2012 9:46 pm

Re: Table view record selected or not

Postby omar » Tue Jul 17, 2012 10:47 pm

Hi,

getSelectedIndex() shows the currently active record or record that was selected by the user. When the form opens, the first record gets "selected" by default. I understand you don't want this initial selection to count as a selection by the user. What you could do is add a vorm var:

Code: Select all
var _initialSelection = true;


and in the onRecordSelection set it to false. Then when the user clicks the button you can test the form variable to see if it is a valid selection or not.

I hope this is what you mean?

Kind regards,
Intrasoft / JBS Group, Partner
Omar van Galen
Servoy Developer
omar
 
Posts: 316
Joined: Sat Feb 12, 2011 4:51 pm
Location: Intrasoft, The Netherlands

Re: Table view record selected or not

Postby hardina09 » Wed Jul 18, 2012 4:34 pm

Awesome. It worked. Thanks Robert and Omar.
hardina09
 
Posts: 62
Joined: Tue Apr 24, 2012 9:46 pm


Return to How To

Who is online

Users browsing this forum: No registered users and 1 guest