Page 1 of 1

Table view record selected or not

PostPosted: Tue Jul 17, 2012 4:38 pm
by hardina09
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.

Re: Table view record selected or not

PostPosted: Tue Jul 17, 2012 7:26 pm
by ROCLASI
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 ?

Re: Table view record selected or not

PostPosted: Tue Jul 17, 2012 7:42 pm
by hardina09
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.

Re: Table view record selected or not

PostPosted: Tue Jul 17, 2012 10:47 pm
by omar
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,

Re: Table view record selected or not

PostPosted: Wed Jul 18, 2012 4:34 pm
by hardina09
Awesome. It worked. Thanks Robert and Omar.