cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
ABI
ABI
Level III

JSL: Update/redraw ListBox's contents

I have a ListBox ("listDisplay") that is initialized with an empty list ("workingList") on a form.

 

As the user works through the form, new entries are added to "workingList". Is there a way to force "listDisplay" to redraw itself with the updated "workingList" on demand? I've tried <<UpdateWindow, but that didn't do the trick.

 

If that doesn't work, how can I tell "listDisplay" to overwrite its currently displayed values with the updated incarnation of "workingList"? I looked through the scripting index but couldn't find the function.

 

One last thing...if anyone knows a way to circumvent the need for "workingList", I'm all ears. I suppose there's something clever that could be done with calling <<Get on the ListBox itself, but I'm at a loss.

 

Stripped-down example code:

 

workingList = {};
New Window( "Example",
	<<Modal,
	H List Box(
		V List Box(
			clb = Col List Box( All ),
			Button Box( "Add", 
				workingList = Insert(workingList, clb<<get selected);
				//redraw listDisplay?
			),
			listDisplay = List Box( workingList ),
		),
	), 
);

 

 Also -- why isn't my JSL code being highlighted in the box above? I'm using the "Insert JSL Script" button on the toolbar. Is there something else that needs to be done?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JSL: Update/redraw ListBox's contents

check this one out

dt=current data table();
New Window( "Example",
	<<Modal,
	H List Box(
		V List Box(
			clb = Col List Box( ),
			clb << append(  dt << get column names ),
			Button Box( "Lot Column",
							 LotCold << Append(  clb << GetSelected )
						),
						 LotCold = Col List Box(
						),
		),
	), 
);

Look at the File Exchange for:

  Runs Test (Wald-Wolfowitz Test) and JSL Implementation of JMP Platform Dialog Box 

For an example of a fairly complete implementation of the JMP Platform dialog box, with filtering, recall, help, etc.  All of which can be ported easily to other scripts.

Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: JSL: Update/redraw ListBox's contents

check this one out

dt=current data table();
New Window( "Example",
	<<Modal,
	H List Box(
		V List Box(
			clb = Col List Box( ),
			clb << append(  dt << get column names ),
			Button Box( "Lot Column",
							 LotCold << Append(  clb << GetSelected )
						),
						 LotCold = Col List Box(
						),
		),
	), 
);

Look at the File Exchange for:

  Runs Test (Wald-Wolfowitz Test) and JSL Implementation of JMP Platform Dialog Box 

For an example of a fairly complete implementation of the JMP Platform dialog box, with filtering, recall, help, etc.  All of which can be ported easily to other scripts.

Jim
ABI
ABI
Level III

Re: JSL: Update/redraw ListBox's contents

Thank you, Jim, this works beautifully. I've grabbed your Runs Test addin and can already tell it's going to help immensely with my current project.

 

While I have your ear, would it be possible to do something like resize the number of entry boxes in a NumberColEditBox based on the currently displayed list size of ListBox? I couldn't find an example of this behavior elsewhere.

 

dt = Current Data Table();
New Window( "Example",
	<<Modal,
	H List Box(
		V List Box(
			clb = Col List Box(),
			clb << append( dt << get column names ),
			Button Box( "Lot Column", 
				LotCold << Append( clb << GetSelected ),
				//Increase # of edit boxes available in NumBox so that it's equal to number of entries in LotCold?
			),
			LotCold = List Box(),
			NumBox = NumberColEditBox("",{}),
		),

	),

);

 

 

PS: You probably don't remember me, but we had talked briefly at the jmp summit a few months back. It's great to see you here -- you'd given me a couple of great pointers for working in jsl, and working in general ("the best work gets accomplished in the morning"). Thanks again!

txnelson
Super User

Re: JSL: Update/redraw ListBox's contents

try this

dt = Current Data Table();
New Window( "Example", 
	//<<Modal,
	H List Box(
		V List Box(
			clb = Col List Box(),
			clb << append( dt << get column names ),
			Button Box( "Lot Column",
				LotCold << Append( clb << GetSelected );
				numbox << delete;
				myvalues = [];
				For( i = 1, i <= N Items( lotcold << get items ), i++,
					myvalues = V Concat( Myvalues, i )
				);
				thevlb << append( numbox = Number Col Edit Box( "", myvalues ) );
				//Increase # of edit boxes available in NumBox so that it's equal to number of entries in LotCold?
			),
			LotCold = List Box(),
			Text Box( "The Number Col Edit Box" ),
			thevlb = V List Box( numbox = Number Col Edit Box( "", [] ) )
		)
	)
);
Jim
ABI
ABI
Level III

Re: JSL: Update/redraw ListBox's contents

Beautiful, thanks again