Datagrid: changing cell style

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Zax
Posts: 432
Joined: Mon May 28, 2007 10:12 am
Location: France

Datagrid: changing cell style

Post by Zax » Sat Nov 16, 2019 2:56 pm

Hello,

If a Datagrid cell is a checkbox, is there a way to modify the colors - foreground or background - of *another* cell of the same line, when the checkbox is clicked?

Thank you.

MichaelBluejay
Posts: 222
Joined: Thu Jul 01, 2010 11:50 am

Re: Datagrid: changing cell style

Post by MichaelBluejay » Fri Nov 22, 2019 3:02 am

I could probably figure out how to do this, *if* I could first figure out how to either get a checkbox into a DG table, or multiple columns into a DG form. I just spent half an hour trying to figure out how to do that before giving up. The DG documentation is simply atrocious. Can you give me a step-by-step to get a simple DG set up so I can work on your issue?

Zax
Posts: 432
Joined: Mon May 28, 2007 10:12 am
Location: France

Re: Datagrid: changing cell style

Post by Zax » Fri Nov 22, 2019 8:04 am

Sorry, I can't... For several reasons:

1 - I only used some DG tables, and not forms.
2 - I spent much more than half an hour to understand how to put a button in a column, so I'm very far to be a DG master.
3 - Each time I modify a DG, I first save a copy of the stack, because very often I made something wrong with the DG, something that doesn't seem to be undoable.
4 - DG are atrocious. It's not the documentation.
5 - My english is not good enough to write accurate help.
6 - At least, a video tutorial would be better.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Datagrid: changing cell style

Post by bogs » Fri Nov 22, 2019 10:47 am

MichaelBluejay wrote:
Fri Nov 22, 2019 3:02 am
I could probably figure out how to do this, *if* I could first figure out how to either get a checkbox into a DG table, or multiple columns into a DG form. I just spent half an hour trying to figure out how to do that before giving up. The DG documentation is simply atrocious. Can you give me a step-by-step to get a simple DG set up so I can work on your issue?
*Disclaimer* I don't work with DGs much.

I *think* you would place a check box just as you would a button in the DG , however, there is a lesson specifically about placing a checkbox into one.

http://lessons.livecode.com/m/datagrid/ ... -data-grid
Image

MichaelBluejay
Posts: 222
Joined: Thu Jul 01, 2010 11:50 am

Re: Datagrid: changing cell style

Post by MichaelBluejay » Fri Nov 22, 2019 8:27 pm

bogs, that lesson is for DG forms, not tables, or at least that's what it says. I tried to make it work for tables but couldn't. Maybe it does, but again, the lesson isn't written well.

Zax, try helping me get a checkbox into a DG table. DGs are indeed a pain, but the documentation is far worse than the DG itself. If we could easily understand how to use them, we wouldn't complain as much.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Datagrid: changing cell style

Post by FourthWorld » Fri Nov 22, 2019 8:46 pm

Zax wrote:
Sat Nov 16, 2019 2:56 pm
If a Datagrid cell is a checkbox, is there a way to modify the colors - foreground or background - of *another* cell of the same line, when the checkbox is clicked?
A checkbox can respond to mouse events to set properties of other objects. Both the object being clicked and the object being affected are members of the same row group, e.g., they have the same owner. So putting that together, off the top of my head it might be something like:

Code: Select all

on mouseUp
  set the backgroundColor of fld "Cell2" of the owner of me to "blue"
end mouseUp
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Zax
Posts: 432
Joined: Mon May 28, 2007 10:12 am
Location: France

Re: Datagrid: changing cell style

Post by Zax » Sat Nov 23, 2019 11:05 am

FourthWorld wrote:
Fri Nov 22, 2019 8:46 pm
A checkbox can respond to mouse events to set properties of other objects. Both the object being clicked and the object being affected are members of the same row group, e.g., they have the same owner. So putting that together, off the top of my head it might be something like:

Code: Select all

on mouseUp
  set the backgroundColor of fld "Cell2" of the owner of me to "blue"
end mouseUp
Interesting. I just tried the owner but, as DG are made with lots a imbricated groups, I was unable to get a pointer to the current line.
I also tried with:

Code: Select all

the owner of (the owner of (the owner of me)) [...]
but it seems endless.

@MichaelBluejay: bogs' link is a good lesson and seems to work for tables too.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Datagrid: changing cell style

Post by jacque » Sat Nov 23, 2019 4:52 pm

that lesson is for DG forms, not tables
DG tables are for text display only. If you need to embed LC controls like buttons or images you have to use a form.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Datagrid: changing cell style

Post by FourthWorld » Sat Nov 23, 2019 7:25 pm

jacque wrote:
Sat Nov 23, 2019 4:52 pm
that lesson is for DG forms, not tables
DG tables are for text display only. If you need to embed LC controls like buttons or images you have to use a form.
The row template for list style DGs is not editable?

Then yes, to edit the row template would require using the type that's editable.

I never use the list DG type anymore, since list fields are more efficient and now support independent column alignment.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Datagrid: changing cell style

Post by jacque » Sat Nov 23, 2019 7:52 pm

The row template for list style DGs is not editable?
It's been a long time since I used it, but unless things have changed there is no template for the basic table display. Like you, I find regular LC fields sufficient for what I do, but I think they'd be useful for situations where there may be more rows than a field can comfortably manage.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Datagrid: changing cell style

Post by FourthWorld » Sat Nov 23, 2019 9:24 pm

Hmmm...if the OP has added a checkbox to the row template, wouldn't that mean he's not using the list type?

Zax wrote:
Interesting. I just tried the owner but, as DG are made with lots a imbricated groups, I was unable to get a pointer to the current line.
A DG row is a group containing the individual controls to be shown for each row. There are as many rows as there are visible on screen within the current bounds of the DG, which is itself a group.

In all my my own use with the DG over the years, simply referring to other controls by referencing the immediate parent has always worked, as in my example above. Indeed, I can't conceive of a way that could not work.

Yes, it's also possible to reference other parents further up, such as the DG itself, the card the DG is on, or the stack that card is in. But those should not be necessary for what you want to do.

If you have a moment to toss together an example in which referring to another control by referencing its common immediate parent isn't working I'd be happy to take a look at it to determine where it went wrong.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Datagrid: changing cell style

Post by jacque » Sat Nov 23, 2019 9:33 pm

His second post seems to indicate he couldn't figure out how to get a checkbox into a list table.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Datagrid: changing cell style

Post by jameshale » Sun Nov 24, 2019 1:49 am

The DataGrid Helper (DGH) provides the tools to add checkboxes, radio buttons, menu buttons, navigation buttons and more to columns in a table view. Indeed you can add any of the classic controls.
You are in effect modifying the column's template (basically replacing the field with the added control), and modifying the columns behaviour script.
You can of course do this the long way (i.e. do all the mods yourself) or use DGH.
DGH is open source for non-commercial use. commercial use requires a license.
Check out the docs (see how to add things to columns) at https://www.aslugontheroad.com/ourprodu ... hat-is-dgh

MichaelBluejay
Posts: 222
Joined: Thu Jul 01, 2010 11:50 am

Re: Datagrid: changing cell style

Post by MichaelBluejay » Sun Nov 24, 2019 7:22 am

jameshale wrote:
Sun Nov 24, 2019 1:49 am
You can of course do this [add a button to a table-based DG] the long way (i.e. do all the mods yourself)...
Could you, or somebody, please provide clear step-by-step instructions on how to do that?

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Datagrid: changing cell style

Post by jameshale » Sun Nov 24, 2019 7:54 am

I have used DGH since it was first released and have not ever attempted to do what it does so effortlessly.
Why not download the trial of DGH and see what it can do.
Otherwise someone in the know may be able to provide the steps to do it without DGH.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”