Page 1 of 1

Checkbox in datagrid = true

Posted: Mon Nov 09, 2015 11:45 pm
by Pahbie
Hi -
I am new to LiveCode and have gotten pretty far within the first 2 weeks of working on things.

I have created a database in the cloud with MySQL.
I have created a Datagrid on a card and have been able to populate it with data.
I have utilized DBGHelper in order to put a checkbox into a column. (I have created the column checkbox without DBGH as well).

What I am not able to do though, is reflect the data value of TRUE from the database in the checkbox.

So - I have columns: LastName, FirstName and DONE. The DONE is the Boolean value in the database or TinyBit(1) value. When I populate the datagrid from the cloud, I would like DONE to show a value as a CHECKED box in the appropriate column.

I at a loss. Thank you in advance.
Pahbie

Re: Checkbox in datagrid = true

Posted: Tue Nov 10, 2015 11:11 am
by MaxV
The property is the hilited:

Code: Select all

set the hilited of button mycheck to true

Re: Checkbox in datagrid = true

Posted: Tue Nov 10, 2015 2:45 pm
by Mikey
Just one other suggestion on this, that might make life easier: You can also use just a normal column, so that you don't have to use a custom layout. In that case, you just put an "X" in the column for true and either a blank or a "-" for false. Then, you can respond to the mouse or any other events and toggle the values...

Re: Checkbox in datagrid = true

Posted: Tue Nov 10, 2015 7:46 pm
by Pahbie
MaxV wrote:The property is the hilited:

Code: Select all

set the hilited of button mycheck to true
Thank you for answering (both of you!)

Where would I insert this code?

Thank you so much!

Re: Checkbox in datagrid = true

Posted: Tue Nov 10, 2015 8:10 pm
by Pahbie
I have figured it out thanks to the lead taken from your posts.

In the behavior of the button in the FillinData pData procedure, I inserted:
if Pdata="1" then
set the hilited of button "Done" of me to true
else

"" to false


Thank you so much for the pointer!

Re: Checkbox in datagrid = true

Posted: Wed Nov 11, 2015 12:06 am
by Klaus
Hi Pahbie,

1. welcome to the forum! :D

2. You can have it shorter like this:
...
set the hilited of button "Done" of me to (Pdata="1")
...
The use of parens "forces" the engine to first evaluate the expression in parens,
so this will even work if Pdata might be empty or whatever! 8)


Best

Klaus

Re: Checkbox in datagrid = true

Posted: Wed Nov 11, 2015 1:23 am
by Pahbie
Thank you Klaus!
I am having a blast with this!

Re: Checkbox in datagrid = true

Posted: Thu Nov 12, 2015 2:36 pm
by Klaus
Pahbie wrote:Thank you Klaus!
I am having a blast with this!
I just love mister Boole! :D