Skip to main content

Question about scoping data in a multi-level Manipulate construction


Background: In a module containing an outer / inner manipulate I select the key of data with a dropdownlist in the outer manipulate. Data is read and displayed in the inner manipulate for edit purposes. The outer manipulate contains buttons, one of which is a save button. I want to get the edited data back at that level so that it can be saved.


Consider the following simplified example:



  Manipulate[
Column[{j,
Manipulate[k, {k, 1, 5, 1}],
Button["Check", Print[k]]
}],
{j, 1, 10, 1}]

the question then becomes: "What is the best way to get the variable k scoped to the first / outer manipulate" ?



Answer



How about this:



DynamicModule[{k},
Manipulate[
Column[{j,
Manipulate[k, {k, 1, 5, 1}, LocalizeVariables -> False],
Button["Check", Print[k]]
}],
{j, 1, 10, 1}]
]

Comments