1 (edited by dbk 2018-11-14 18:25:24)

Topic: [SOLVED] Problems when search involves a checkbox (boolean value)

Hello friends,

I am trying to make a tablegrid that i can filter (= search) based upon the values of textboxes/comboboxes and checkboxes. My table has a field with a boolean value, the data is entered in to the db by checkbox.

My search works perfectly if i try to search using a textbox or combobox or both. However, when i try to search with a checkbox, it will also display the results perfectly, but when i uncheck it seems it doesn't go back to the initial state (like it doesn't know that the checkbox is unchecked). I am probably doing something wrong but i can't figure it out.

The search is made through mvdb, no script.

Kind regards

2 (edited by derek 2018-11-13 20:01:07)

Re: [SOLVED] Problems when search involves a checkbox (boolean value)

Hi DBK,
Just a thought - have you tried setting the checkbox 'allowgrayed' property to 'true'? (please see attached screenshot).
If you don't, you'll find that when used as a filter, you'll get rows that ARE checked, rows that ARE NOT checked, but you won't be able to see ALL rows.
I'd be careful using different combinations of filters (edit, combobox and checkbox) as it can get quite confusing for the User (just a personal opinion).  If you do use a number of different filters, it's often worth having a 'reset' button that un-filters everything all at once.
I'm sure I've got an old project somewhere with lots of different filter options - if it's any use to you, I can try and find it and upload it.
Regards,
Derek.

Post's attachments

Attachment icon checkbox.jpg 88.46 kb, 222 downloads since 2018-11-13 

Re: [SOLVED] Problems when search involves a checkbox (boolean value)

derek wrote:

Hi DBK,
Just a thought - have you tried setting the checkbox 'allowgrayed' property to 'true'? (please see attached screenshot).
If you don't, you'll find that when used as a filter, you'll get rows that ARE checked, rows that ARE NOT checked, but you won't be able to see ALL rows.
I'd be careful using different combinations of filters (edit, combobox and checkbox) as it can get quite confusing for the User (just a personal opinion).  If you do use a number of different filters, it's often worth having a 'reset' button that un-filters everything all at once.
I'm sure I've got an old project somewhere with lots of different filter options - if it's any use to you, I can try and find it and upload it.
Regards,
Derek.

Hello Derek,

Many many thanks (again!), this did the trick!
When i allow grayed all rows show up, which is great.

Do you know if there is a way i can set the property 'allowgrayed' automatically (syntax)?
Like: Form1.CheckBox1.allowGreyed;
This way i could see all results.

Or would it be better to just add a button to clear all values from the search filters?

Re: [SOLVED] Problems when search involves a checkbox (boolean value)

Hi,
The syntax is
form1.CheckBox1.State := cbgrayed;
Please have a look at the attachement - I used a button to clear both of the checkboxes but, if you wanted to avoid using a script, you could just toggle each checkbox until each state is greyed etc.
If you have checkboxes,  comboboxes and edit fields all being used as filters, I'd definitely use a 'reset' button (I'm lazy!!!).
Hope this helps,
Derek.

Post's attachments

Attachment icon checkboxcount.zip 337.63 kb, 428 downloads since 2018-11-13 

Re: [SOLVED] Problems when search involves a checkbox (boolean value)

Hello derek,

Thanks again for your help, it works perfectly!
Also thank you very much for your example, i also learned something new from this: clever how you integrated the checkbox in the grid.