Help with datagrid behavior script(attempting to have many)

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
karimariesk
Posts: 10
Joined: Thu Jul 07, 2016 6:44 am

Help with datagrid behavior script(attempting to have many)

Post by karimariesk » Fri Jul 29, 2016 6:08 am

Hello! In my stack i have several cards that use datagrids. for each i wrote a customized behavior script. the problem is that the behavior overwrite eachothers. I mean, not overwrite but more like i cant have several of them, just one centralized one. i would like to have several localized behavior scripts instead. in the livecode lessons i found something similar, a way to locally overwrite the Field Editor of a datagrid. But i didnt find a way to do this with the behavior script.
Any ideas?
Thanks in advance!
Karen

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Help with datagrid behavior script(attempting to have ma

Post by Mikey » Fri Jul 29, 2016 2:33 pm

How are you trying to get into the script? Do you understand the difference between object scripts and behavior scripts?

You should be editing the object script of each of the datagrids. Right-click on the datagrid and select "Edit Script". The script editor should be empty, and the tab should say 'group "dataGrid 1".

If you are editing the behavior script for the datagrid, you are editing the shared behavior for all datagrids in your project.

karimariesk
Posts: 10
Joined: Thu Jul 07, 2016 6:44 am

Re: Help with datagrid behavior script(attempting to have ma

Post by karimariesk » Fri Jul 29, 2016 7:13 pm

yes!! i've been editing the wrong script then!! thank you so much!!
Another question... same thing happens with the row template, how do i fix that?

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Help with datagrid behavior script(attempting to have ma

Post by Mikey » Fri Jul 29, 2016 7:45 pm

Did you possibly copy/paste the same DG on multiple cards?

karimariesk
Posts: 10
Joined: Thu Jul 07, 2016 6:44 am

Re: Help with datagrid behavior script(attempting to have ma

Post by karimariesk » Fri Jul 29, 2016 8:08 pm

Actually yes, I did that. but then an error appeared and i deleted the datagrids and made individual ones. Now im trying to do as you said, but i cant get the datagrid to execute the object script i put, instead of the default behavior one. So im trying to follow the lesson of "How Do I Override the Default Behavior For Rendering Data to a Cell?" but i get an error in the message box. i change it from the "default column behavior" that is used in the example, to "behavior script" which is what appears next to row behavior in the second tab of the inspector when im selecting the datagrid.
Im sure im making some foolish mistake, im in in this afterall, so your help is greatly appreciated!

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Help with datagrid behavior script(attempting to have ma

Post by Mikey » Fri Jul 29, 2016 8:11 pm

Well, post the stack, so we can have a look at it.

karimariesk
Posts: 10
Joined: Thu Jul 07, 2016 6:44 am

Re: Help with datagrid behavior script(attempting to have ma

Post by karimariesk » Fri Jul 29, 2016 8:32 pm

Here's the troublesome card. seriously, thanks for helping me!
Attachments
datagrid.rar
(4.71 KiB) Downloaded 255 times

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Help with datagrid behavior script(attempting to have ma

Post by Mikey » Fri Jul 29, 2016 9:18 pm

So what are we trying to do? I see you don't have the column behavior set. You have to

Code: Select all

set the dgprops["default column behavior"] of group "dataGrid 1" to the long id of selObj()
to make the script of the button the behavior script. That's on page 127.

karimariesk
Posts: 10
Joined: Thu Jul 07, 2016 6:44 am

Re: Help with datagrid behavior script(attempting to have ma

Post by karimariesk » Fri Jul 29, 2016 9:28 pm

but isnt the column behavior script only for datagrid tables? im using a form. Is it the same?

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Re: Help with datagrid behavior script(attempting to have ma

Post by jameshale » Fri Jul 29, 2016 11:44 pm

LC 8.1 DP3 has just been released which has an updated version of the Data Grid docs that takes into account version 8 IDE changes. It also corrects a bug with the 'refresh data grid' button so that it now works.
To access the updated docs, open the dictionary and select the "guide" tab. You will see the DG docs there.
Also note that selecting "User Guide" from the help menu will produce a searchable pdf of all the guides in the dictionary.

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Help with datagrid behavior script(attempting to have ma

Post by Mikey » Sat Jul 30, 2016 3:57 pm

So what isn't working? The mousedoubleup? You didn't have your cells set as modifiable. When I changed that it worked better, too.

karimariesk
Posts: 10
Joined: Thu Jul 07, 2016 6:44 am

Re: Help with datagrid behavior script(attempting to have ma

Post by karimariesk » Sun Jul 31, 2016 8:15 am

I have multiple datagrids, and they where overwriting eachothers row templates and behaviors for some reason(that reason being that i had made a horrible mistake and edited the wrong script). I tried diferent things but the problems persisted. But when i open the project today it somehow had fixed itself. I havent tested it well yet, but i think it is really fixed. Thanks a lot for your help! I'll post again after doing more tests.

Post Reply