gingercat
Posts: 48
|
| Posted: 10/06/2010, 8:18 PM |
|
I have a list box used as a search for a standard grid. The option values are populated from a SQL query. I want to be able to check the number of values and if they're less than 3 make the whole search from invisible.
I have working code that's no problem but the part I cant' work out is how to find out how many option values are actually in the list box
|
 |
 |
datadoit
|
| Posted: 10/07/2010, 5:43 AM |
|
Since the listbox values are pulled via SQL, then include in your query
SELECT COUNT(keyfield) AS Count, blah blah blah. In the listbox's
BeforeShow you can test for that value.
if ($Component->ds->f("Count") > 3) {
Do this;
}
|
|
|
 |
gingercat
Posts: 48
|
| Posted: 10/08/2010, 2:29 PM |
|
In theory the following should work in the BeforeShow event:
if ($FormSearch->s_phone->DataSource->RecordsCount < 3) {
$FormSearch->Visible = false;
}
else $FormSearch->Visible = true;
but RecordsCount always returns 0 - any ideas why?
what does the f method mean in your above example - It doens't comeu p as an autocomplete for me
I'm using MSSQL and never did get the above SQL to work
|
 |
 |
CodeChargeMVP
Posts: 473
|
| Posted: 10/11/2010, 10:06 AM |
|
I donīt know if this would be helpful,
but on javascript the listbox object has a property called length,
so that you can retrieve the number of options available this way:
option_numbers = document.forms["yourform"].elements["yourobjectelementlistbox"].length;
or
option_numbers = window.document.getelementById("youridobjectlistbox").length;
Iīd concern about than the BeforeShow event is no the right event because maybe
as it says on before show, maybe the form values hasnīt been retrieved yet,so thatīs
maybe why the property returns all the time 0.
Iīd check the help from CSS and see which event would fix.
Quote gingercat:
In theory the following should work in the BeforeShow event:
if ($FormSearch->s_phone->DataSource->RecordsCount < 3) {
$FormSearch->Visible = false;
}
else $FormSearch->Visible = true;
but RecordsCount always returns 0 - any ideas why?
what does the f method mean in your above example - It doens't comeu p as an autocomplete for me
I'm using MSSQL and never did get the above SQL to work
_________________
Best Regards
Entrepeneur | NT Consultant
|
 |
 |
|