cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to create a two column user input modal window where the second column is populated based on single input on first column?

I would like to create a two column user input modal window where the user input goes into the first column (single input box) for a "parent part ID", based on which adjacent second column window entries (child part IDs) get populated.

  • The entries in the second column come from a database query (for which I already have a script). A "parent part ID" can have one or more than one "child part IDs"
  • This query script needs to run upon a checkbox being checked adjacent to the parent part ID input box after the input.
  • Once one or more than one child part IDs (as the case may be) are selected in the second column (again using checkbox), press of the OK button at the bottom of the modal window is to make the selected entries in second column available (as a list) for a follow on script to use.
  • A select all option for the entries in the second column would be an added advantage. 

I would appreciate if I can get some ideas on how to proceed with this in JSL?

When it's too good to be true, it's neither
21 REPLIES 21
Neo
Neo
Level VI

Re: How to create a two column user input modal window where the second column is populated based on single input on first column?

@jthi Thanks, I would have never figured that out.

However, the updated script below is not passing the value of returnedPid as an argument to my function fetchChildIds (:

Names Default To Here (1);
clear log ();
include ("_fetchChildIds.jsl");
//aa_parents << Set Default Value({});

get_childids = function({this}, {Default Local},
	//new_childids = aa_parents[(this << prev sib) << get text];
		new_childids = fetchChildIds (returnedPid);
	lb_child << Set items(new_childids);
	);
	
nw = New Window("Fetch Summary Data ", << Modal, <<Return Result,
	H List Box(
		Panel Box("[1] Enter Parent ID", //sets outside panel
			Lineup Box(N Col(2),
			pid = Text Edit Box("", << Set Width(150)),	
				Button Box("Get Child ID(s)", 
				returnedPid = pid << get text, // this = pid << get text, //also does not seem correct
				<< set function(function({this},
					get_childids(this); 
				)))
			)
		),
		Panel Box("[2] Select Child ID",
			H List Box(
				lb_child = List Box({}),
				Lineup Box(N Col(1),
					Button Box("Select All", 
						For Each({item, idx}, lb_child << get items,
							lb_child << Set Selected(idx);
						);
						wait(0);
					),
					Button Box("Unselect All",
						lb_child << Clear selection;
					),
				)
			)
		),
		Panel Box("[3] Fetch Test Data",
			Lineup Box(N Col(1),
				Button Box("OK"),
				Button Box("Cancel")
			)
		)
	)
);
When it's too good to be true, it's neither
jthi
Super User

Re: How to create a two column user input modal window where the second column is populated based on single input on first column?

You really should read through scripting guide and check out scripting index to understand what is going on.

Names Default To Here (1);

get_childids = function({user_input}, {Default Local},
	show(user_input);
	// do something
	// get return value...
	retval = user_input; // for demo purposes
	return(retval);
);
	
nw = New Window("Fetch Summary Data ",
	H List Box(
		Panel Box("[1] Enter Parent ID", //sets outside panel
			Lineup Box(N Col(2),
			pid = Text Edit Box("", << Set Width(150)),	
				Button Box("Get Child ID(s)", 
					user_input = pid << get text;
					childids = get_childids(user_input);
					// do something with childids (or do it outside within the function but change the function name)
				);
			)
		)
	)
);
-Jarmo