Datagrid form and behaviours

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
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Datagrid form and behaviours

Post by jalz » Tue Dec 24, 2013 1:09 am

Hi Guys,

I've got a card called Controls which contains a combo box control with some code attached to on mouse enter handler. The code executes perfectly on this card just how I expect it. The ID for that button is 1035.

On another card, I've got a data grid and I have altered the row template to suit my input requirements. One of buttons on the data grid row contains a combobox which I've named the same as the one on the Controls stack. I would like to attach the behaviour of the Combobox in Controls card to this so I've got the following script on the object in the data grid.

Code: Select all

 global gConnID,gList

on mouseEnter
   set the behavior of btn id 1104 to THE LONG ID OF btn id 1035 of stack "Controls"
end mouseEnter
When I try accessing the data grid on browse mode, I get the following error (the combo box in the data grid has an id of 1103):
Chunk: no such object
Object cb_chargerate
Line set the behavior of btn id 1103 to THE LONG ID OF btn id 1035 of stack "Controls"
Hint 1103


I'm assuming the id's of objects change when they are in the data grid as they're so many instances of the objects per row, but I've tried the message watcher and can't seem to figure out what the button id of the source is in browse mode. Can someone point me in the right direction please?

Thanks
Jalz

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: Datagrid form and behaviours

Post by jalz » Tue Dec 24, 2013 11:24 pm

Hi all,

figured it out, had to go to the beginning of the DataGrid Api and understand how the object is built and grouped of many other objects. Each repetition of a row contains a different set of numbers, so the code that eventually worked is below.

Code: Select all

   put the short id of me into myVar
   set the behavior of btn id myVar to THE LONG ID OF btn id 1035 of stack "Controls"

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

Re: Datagrid form and behaviours

Post by Klaus » Wed Dec 25, 2013 1:32 pm

Hi jalz,

merry chistmas etc... :D

Any special reason to do this in RUNTIME?
Why not prepare that namely combo box with the correct behavior
in the "template" group of that datagrid? Just curious 8)

Best

Klaus

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: Datagrid form and behaviours

Post by jalz » Wed Dec 25, 2013 5:40 pm

Hi Klaus

Merry Xmas and happy holidays to you too.

No real reason why I'm doing it in runtime. It was the only way I could work out how to do it by following a tutorial I found, but then again I'm learning and I'm sure there is an easier way to do this?

Datagrids seem to be quite difficult to master, I'll check out how to add behaviour to the template group of the data grid

Jalz

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

Re: Datagrid form and behaviours

Post by Klaus » Wed Dec 25, 2013 5:52 pm

Hi jalz,
jalz wrote:Datagrids seem to be quite difficult to master,...
you BET! :D

Everytime I use datagrids in my projects I have to read up the complete docs over and over and over... :shock:


Best

Klaus

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Datagrid form and behaviours

Post by LC4iOS » Thu Dec 26, 2013 12:12 am

Yes, with data grids I found the tutorials priceless.
No way I could have sorted it out otherwise.
So much faster accomplishing goals working thru the tutorials.
Everything I've wanted to do so far has already been covered by the tutorials.
(except for fonts, etc)


I had to stop trying it my way and just do everything the way the tutorials outline in the procedures.

Don't forget to search by LiveCode DataGrid Sample and LiveCode DGH (dataGrid Helper, if you have it, priceless)
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Post Reply