Page 1 of 1

Datagrid form and behaviours

Posted: Tue Dec 24, 2013 1:09 am
by jalz
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

Re: Datagrid form and behaviours

Posted: Tue Dec 24, 2013 11:24 pm
by jalz
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"

Re: Datagrid form and behaviours

Posted: Wed Dec 25, 2013 1:32 pm
by Klaus
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

Re: Datagrid form and behaviours

Posted: Wed Dec 25, 2013 5:40 pm
by jalz
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

Re: Datagrid form and behaviours

Posted: Wed Dec 25, 2013 5:52 pm
by Klaus
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

Re: Datagrid form and behaviours

Posted: Thu Dec 26, 2013 12:12 am
by LC4iOS
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)