Page 1 of 2
Datagrid: changing cell style
Posted: Sat Nov 16, 2019 2:56 pm
by Zax
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.
Re: Datagrid: changing cell style
Posted: Fri Nov 22, 2019 3:02 am
by MichaelBluejay
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?
Re: Datagrid: changing cell style
Posted: Fri Nov 22, 2019 8:04 am
by Zax
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.
Re: Datagrid: changing cell style
Posted: Fri Nov 22, 2019 10:47 am
by bogs
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
Re: Datagrid: changing cell style
Posted: Fri Nov 22, 2019 8:27 pm
by MichaelBluejay
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.
Re: Datagrid: changing cell style
Posted: Fri Nov 22, 2019 8:46 pm
by FourthWorld
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
Re: Datagrid: changing cell style
Posted: Sat Nov 23, 2019 11:05 am
by Zax
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.
Re: Datagrid: changing cell style
Posted: Sat Nov 23, 2019 4:52 pm
by jacque
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.
Re: Datagrid: changing cell style
Posted: Sat Nov 23, 2019 7:25 pm
by FourthWorld
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.
Re: Datagrid: changing cell style
Posted: Sat Nov 23, 2019 7:52 pm
by jacque
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.
Re: Datagrid: changing cell style
Posted: Sat Nov 23, 2019 9:24 pm
by FourthWorld
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.
Re: Datagrid: changing cell style
Posted: Sat Nov 23, 2019 9:33 pm
by jacque
His second post seems to indicate he couldn't figure out how to get a checkbox into a list table.
Re: Datagrid: changing cell style
Posted: Sun Nov 24, 2019 1:49 am
by jameshale
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
Re: Datagrid: changing cell style
Posted: Sun Nov 24, 2019 7:22 am
by MichaelBluejay
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?
Re: Datagrid: changing cell style
Posted: Sun Nov 24, 2019 7:54 am
by jameshale
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.