Trying to figure out the best way to populate the contents of an option menu in a datagrid column. I have two scenarios.
First scenario is that the data in the option menu needs to be populated once when the card opens and won;t change again until the card is closed and opened again. I'm looking for the best place put the population code so it only gets executed once when the card opens. Feels like the option menu in the Row Template is what should be populated so that I don;t have to populate each copy of the option menu that is displayed in the datagrid. Would that perhaps be a custom behaviour for the option menu?
Second scenario is that the the contents of the option menu in column B changes dependant on the data entered by the user in column A (column A is also an option menu but it's contents fall under the first scenario). I guess the code to do this would be in a menuPick handler for column A, but I'm having a hard time trying to figure out how to refer to the option menu in column B of the same line as column A
Populating an option menu in a datagrid table
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: Populating an option menu in a datagrid table
Scenario A
Use the preopenCard handler to populate the option menu in the row template for the Data Grid. You can get the row template group like this:
put the dgProp["row template"] of group "DataGrid" into theGroup
Scenario B
I don't think there is an easy way to target particular column controls. Here is what I would do. In the FillInData handler for column B you would populate the menu based on the value of column A (GetDataOfIndex(the dgIndex of me, "column A").
When the user updates the option menu in column a just update the internal Data Grid data and the data grid will redraw, updating the column B menu. Here is a slight variation from the example give in the lesson How Can I Store An Option Menu Value When The User Makes a Selection?:
Use the preopenCard handler to populate the option menu in the row template for the Data Grid. You can get the row template group like this:
put the dgProp["row template"] of group "DataGrid" into theGroup
Scenario B
I don't think there is an easy way to target particular column controls. Here is what I would do. In the FillInData handler for column B you would populate the menu based on the value of column A (GetDataOfIndex(the dgIndex of me, "column A").
When the user updates the option menu in column a just update the internal Data Grid data and the data grid will redraw, updating the column B menu. Here is a slight variation from the example give in the lesson How Can I Store An Option Menu Value When The User Makes a Selection?:
Code: Select all
on menuPick pChosenItem
-- Store column data
SetDataOfIndex the dgIndex of me, the dgColumn of me, pChosenItem
-- Redraw row
RefreshList
end menuPick
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: Populating an option menu in a datagrid table
Thanks Trevor, sounds like both solutions will qork for me.
Pete
Pete