Page 1 of 1
Datagrid Column B line 2 - Background Color specific setting ?
Posted: Tue Mar 02, 2021 1:03 am
by liveme
Hi coders..,
I'd like to know if LC allows one to define a specific CELL of a Datagrid to be of a different background color ?
i.e code below would show modified cells in a kind of a "stair" displayed shape
Col.A Line.1 Background color in RED
Col.B Line.2 Background color in YELLOW
Col.C Line.3 Background color in BLUE
...
I could change the TEXT color (of a full line, All columns.)
but I could not change its Background...even for the full line, and not for just one Cell
Code: Select all
set the foregroundcolor of me to blue -- work if I remember
set the backgroundColor of me to 182,216,255 -- does not work / not even with Word : "red"
set the textcolor of me to green -- works
*Line 2 does not display any change, All Grid lines remain with their original "white" bkg color.. (?)
*if not doable using a Grid...any other way ?
I saw the use of small flags icons... maybe some tricks using few colored Icons could be set at the indivualy selected Cell all accross the datagrid space, not specific to just a single "flag" column ?
Also, I would like each displayed cell color to be linked to a DB dynamic content (if..then... and not need some direct Datagrid in cell editing.
(and if same formula can also make coffee...Even better !

)
Tks
https://lessons.livecode.com/m/datagrid ... in-a-table
Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Tue Mar 02, 2021 9:13 am
by Klaus
Maybe the fields in a datagrid are transparent by default?
In that case you also need to:
Code: Select all
...
set the OPAQUE of me to FALSE
set the foregroundcolor of me to blue -- work if I remember
set the backgroundColor of me to 182,216,255 -- does not work / not even with Word : "red"
set the textcolor of me to green -- works
...
But the only way or better TIME to modify a cell is in the ->
on fillINData handler.
Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Tue Mar 02, 2021 3:04 pm
by dunbarx
Datagrids are composed entirely of standard LC controls. A dataGrid "cell" is simply a field. If you want to change the backColor of any particular one, simply set the opaque of the field to "true", and then set the backColor to whatever.
The fields are numbered, but also named as, say, field "Col 1 0001", which would be the top leftmost field. I would stick to that method of referencing fields.
Craig
Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Tue Mar 02, 2021 9:15 pm
by liveme
Big Thanks guys !!!
works like a charm now...
used true instead of false ..but no biggie
Code: Select all
set the opaque of fld "Col 1 0001" to true
set the foregroundColor of fld "Col 1 0001" to black
set the backgroundColor of fld "Col 1 0001" to blue
Any idea how to reset the whole Grid to non-colored original default state ?
- Would one use some loop for that ?
row 1 to 100
Col 1 to 100
...or a does RANGE definition "from Col1 0001 - Col100 0100" already exit ?
Code: Select all
set the opaque of fld "Col 1 0001" to false
set the opaque of fld "Col 2 0002" to false
Loving LC everyday more !

Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Tue Mar 02, 2021 9:40 pm
by Klaus
Hi liveme,
Any idea how to reset the whole Grid to non-colored original default state ?
simply set the dgdata again!
Code: Select all
...
lock screen
put the dgdata of grp "your dg here" into tData
set the dgdata of grp "your dg here" to empty
set the dgdata of grp "your dg here" to tData
unlock screen
...
This will delete all controls inside of the datagrid and create all neccessary new fields
from the template with their previous content. That's how datagrids work.
Best
Klaus
Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Wed Mar 03, 2021 3:11 am
by liveme
Perfect Klaus, thanks again...works fine !
Now, I noticed that as I close the stack and reopen it.
(Text values are still there*..saved within the stack)
but all coloring is gone !
Question :
If I want to load the Text values + the colors applied, all uploaded from a DB when loading the DGrid card :
- does it mean I'd have to create an EXTRA column so as to store each field background/foreground/...MarsGround...

settings in my SQlite DB ?
- As of now :
what happened to the color that were just just applied, could they be saved before closing card along with the Text values (somewhere in the card/stack) ?
Thank again...
Editing: I found the "Persistent Data" prop to be activated, though this does not relate to the colors prop..
Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Wed Mar 03, 2021 3:51 am
by kdjanz
Perfect job for a custom property that you update on closeCard and refresh on openCard?
Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Wed Mar 03, 2021 11:39 am
by bogs
kdjanz wrote: ↑Wed Mar 03, 2021 3:51 am
Perfect job for a custom property that you
update on closeCard and refresh on openCard?
It should be mentioned that the above will *only* stick if you are using a launcher to launch the program, i.e, that the program storing the cust. prop. is not the standalone.
Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Wed Mar 03, 2021 7:45 pm
by liveme
that the program storing the cust. prop. is not the standalone.
... I'm always confused by the use of "standalone" in LC. I come from a network domain where its used most always to discribe a non networked workstation machine.
Would you mean that an LC Stack does not come with a mechanism to store the colors modified properties, but that one needs to add some sort of extra storage feature to store those, is that the idea ?
tks
Ps: also, I have no idea what is a Launcher to Launch a program - I'm only using the IDE so far, will try to create my first App for Linux ...maybe next week...

Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Wed Mar 03, 2021 7:59 pm
by dunbarx
Hi.
"Standalone" here means a self-contained LC application. It is comprised of one or more stacks and subStacks, and the standalone builder in LC attaches a living, working engine to the bundle. The result is your stack(s) running on any platform without the LC application being resident at all.
Saving anything is another issue. No OS will allow an executable to be modified in any way. So one method, that I use all the time, is to create a stack that is called the "launcher" or "splash" stack. This is the executable, and may or may not have any functionality. But nothing in that stack can be saved.
But it is possible to attach other stacks to the launcher stack file. These can do anything, save anything, whatever. So your launcher stack might do nothing but navigate to your "working" stack and then hide itself. Anything goes once in you are in those other stacks.
Others might use external files to save data or properties. That is fine. The point is that all saving is done outside the launcher.
Craig
Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Wed Mar 03, 2021 8:32 pm
by bogs
dunbarx wrote: ↑Wed Mar 03, 2021 7:59 pm
...create a stack that is called the "launcher" or "splash" stack.
What Craig said can be found here ->
https://lessons.livecode.com/m/4071/l/1 ... pplication
Re: Datagrid Column B line 2 - Background Color specific setting ?
Posted: Thu Mar 04, 2021 9:00 am
by liveme
Thanks Guys,
I sure need to get some standalone apps to test that asap !
I know exe files in Windows would need to store any editable data into some other related files/db along.
I guess a standalone is a similar to a runtime under windows MSAccess, at least thats how it was called sometimes ago - so you did not need to install MSAccess along your mdb app.
Great help guys thanks for clarifying these point !
