Template script for DataGrid

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
guylouis
Posts: 26
Joined: Mon Feb 01, 2016 11:45 pm

Template script for DataGrid

Post by guylouis » Sat Feb 08, 2020 10:27 am

Hi,

I created an option button in a column of a DataGrid. OK, it reacts as I want.

I see there is a script for this option button with some handlers like "on FillInData pData", "on mouseDoubleUp pMouseBtnNum", .....

But how can I script this button to take an action when I click on it?

In a standard option menu, I can script this:

on mouseUp
... Take an action
end mouseUp

But this do not run on the button in the column DataGrid.

How can I do this?

Thanks

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Template script for DataGrid

Post by Klaus » Sat Feb 08, 2020 2:53 pm

Hi guylouis,

read up here:
http://lessons.livecode.com/m/datagrid/ ... -s-columns
and here:
http://lessons.livecode.com/m/datagrid/ ... mns-part-2
Attention: Advanced stuff! 8)

Best

Klaus

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Template script for DataGrid

Post by sritcp » Sat Feb 08, 2020 4:35 pm

Hi guylouis:

1. The structure of Data grid is complicated. The option menu button you put in a column of a DG is inside a nested stream of groups. The long name of one of the buttons in the column, e.g., is
button "Option Menu" of group "MyColumnName 0001" of group "MyColumnName" of group "dgList" of group "dgListMask" of group "DataGrid 1" of card "DG-ButtonsMenusImages" of stack "MyStack"! That is, each button in a column is a different object. If you code one of them, others won't work the same way.

2. So, you have to script the object in the "row template". This is where you specified what should be there in each column (when you created a "table type" DG). Open the object inspector of the DataGrid, click on "Edit Row Template", click further to "Edit Group" until you can select the option button; now you can edit the script of the "template" of your object. Now, whatever you script will be inherited by all the buttons down the column.

3. In option menu buttons, use menuPick message to script its behavior (not mouseUp). The mouseUp message appears to be sent only when menuPick handler is not there. Try this experiment: Make an option menu button on a card (not inside a data grid). Script it as follows:

Code: Select all

on mouseUp
   put "mouseUp was received" into msg
end mouseUp
Test it; it works. Now add the menuPick handler to the script.

Code: Select all

on mouseUp
   put "mouseUp was received" into msg
end mouseUp

on menuPick pChosenItem
   put pChosenItem after msg
end menuPick
Test it; only menuPick is processed.
You can use message watcher to look at the messages that were sent.

Regards,
Sri

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Template script for DataGrid

Post by dunbarx » Sat Feb 08, 2020 5:06 pm

Hi.

What everyone said.

I am only adding something here because new users often jump right into using a dataGrid because it seems like such a compact, good-looking and powerful tool.

It is.

But it is also its own world, quite "apart" from LiveCode, and requires its own learning curve, again, quite apart from LiveCode. All this is just to add my own caveat, as Klaus mentioned. If you can do what you need with "ordinary" controls and groups, I recommend you think about doing so. For example, might a table field serve as the core of what you need?

Otherwise, write back as often you like about your dataGrid journey. It is more than worthwhile becoming conversant with them, as long as the features they offer are needed.

The dataGrid API section will be invaluable.

Craig

guylouis
Posts: 26
Joined: Mon Feb 01, 2016 11:45 pm

Re: Template script for DataGrid

Post by guylouis » Mon Feb 10, 2020 11:50 pm

Hi,

Thanks for all your answers. I have the solution to my problem.

I used "Data Grid Helper 2.5" and all is now fine.

Best, Guy

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”