Datagrid Column B line 2 - Background Color specific setting ?

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

Post Reply
liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

Datagrid Column B line 2 - Background Color specific setting ?

Post by liveme » Tue Mar 02, 2021 1:03 am

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 ! :lol: )

:idea:
Tks










https://lessons.livecode.com/m/datagrid ... in-a-table

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by Klaus » Tue Mar 02, 2021 9:13 am

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by dunbarx » Tue Mar 02, 2021 3:04 pm

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

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by liveme » Tue Mar 02, 2021 9:15 pm

Big Thanks guys !!! :mrgreen:
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 ! :mrgreen:

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by Klaus » Tue Mar 02, 2021 9:40 pm

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

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by liveme » Wed Mar 03, 2021 3:11 am

Perfect Klaus, thanks again...works fine ! 8)

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... :shock: 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..
Last edited by liveme on Wed Mar 03, 2021 7:40 pm, edited 1 time in total.

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by kdjanz » Wed Mar 03, 2021 3:51 am

Perfect job for a custom property that you update on closeCard and refresh on openCard?

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

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by bogs » Wed Mar 03, 2021 11:39 am

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.
Image

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by liveme » Wed Mar 03, 2021 7:45 pm

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... :P

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by dunbarx » Wed Mar 03, 2021 7:59 pm

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
Last edited by dunbarx on Wed Mar 03, 2021 10:32 pm, edited 2 times in total.

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

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by bogs » Wed Mar 03, 2021 8:32 pm

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
Image

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

Re: Datagrid Column B line 2 - Background Color specific setting ?

Post by liveme » Thu Mar 04, 2021 9:00 am

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 ! :wink:
:!:

Post Reply