Datagrid gives error message

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
CAsba
Posts: 368
Joined: Fri Sep 30, 2022 12:11 pm

Datagrid gives error message

Post by CAsba » Mon Dec 11, 2023 11:31 am

Datagrid 3 has 34 columns.Different tasks need some cols showing some hidden. On trying code set col visibility, I get error message "An error has occurred in behaviour for the column template:
Chunk: error in object expression

To ensure I was using the correcvt number of trues and falses I set up the following code; I also ran it with one and two less trues, and with one and two more trues, for in case I had miscounted. Still got the error message. What other anomaly, apart from the wrong number of trues, can be causing the error ? Any ideas ?

Code: Select all

set the dgProps["column visibility"] of group "DataGrid 3" of cd "manage products" to "true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true"
   #######################################################################################  1    2    3    4    5    6    7    8    9   10    11   12   13   14  15    16  17   18   19   20   21    22   23  24   25   26   27   28   29   30   31   32   33   34

stam
Posts: 2692
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Datagrid gives error message

Post by stam » Mon Dec 11, 2023 1:42 pm

you're enclosing your true/false list in quotes. Don't ;)
true/false have native meaning - by enclosing them in quotes you convert them to a string which then means nothing, just a collection of letters.

In other words, the statement should read:

Code: Select all

set the dgProps["column visibility"] of group "DataGrid 3" of cd "manage products" to true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true
If that doesn't fix your problem, do you use any column behaviour scripts? if so, the error may be there.


Having said that with so many columns you're inviting trouble by trying to change them all in one go like this.
Presumably a number of columns will always be true?
If only a smaller number need to change, you may want to use dgColumnIsVisible to manage individual columns instead, e.g.

Code: Select all

set the dgColumnIsVisible["<columnName>"] of group "<dataGridName>" to true|false
This would easier to troubleshoot and while it adds more lines to your handler, it gets rid of the massive lines when you need to change individual columns' visibility.

Stam

CAsba
Posts: 368
Joined: Fri Sep 30, 2022 12:11 pm

Re: Datagrid gives error message

Post by CAsba » Mon Dec 11, 2023 5:02 pm

Thanks for that, Stam, most helpful..
Not the complete solution though.
I found out that any coded instruction, from any card, to the card resulted in the message. I deleted the DG, built another in its place, having copied the data first, and problem solved. Something must ahve gone awry with the dg and LC drew attention to it each time the card was activated.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”