Subscribe Bookmark RSS Feed

create the search button

jade

Contributor

Joined:

Apr 22, 2017

Hi, everyone

Does it have possibility to create the search button by using JSL?
Now my user interface is using the drop down list, user need scroll down to check whether which item they want.
So, i want to make improvement by using search button in order for user to easy search their item.

May I know the JSL has possibility to do it?
Thanks.

10 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

I added a JMP Adding that generates a Runs Test that has a dialog box that has a search available to search through the input columns, much like the search capability for the regular JMP platforms.  The addin is:

    

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

 

Jim
ian_jmp

Staff

Joined:

Jun 23, 2011

Also see 'Help > Scripting Index' and look for 'Filter Col Selector()' (which might be what Jim's code uses).

txnelson

Super User

Joined:

Jun 22, 2012

no, this isn't what I am using......but I may be changing the code to using it........one learns new JMP things every day

Jim
David_Burnham

Super User

Joined:

Jul 13, 2011

Here is some framework code:

dt = Open("$SAMPLE_DATA/Big Class.jmp");
lst = Column(Dt,"Name") << Get Values;
Close(dt,NoSave);

New Window("Test",
	Lineup Box(NCol(1),
		lb = List Box(lst),
		tbSearch = Text Edit Box("",<<Set Hint("search string e.g. ja"),
			<< Set Script(
				// get the search value
				str = Uppercase( tbSearch << Get Text );
				lstNew = {};
				// build a list of matching values
				For (i=1,i<=NItems(lst),i++,
					If (Contains(lst[i],str),
						InsertInto(lstNew,lst[i])
					)
				);
				// display the list of matching values
				lb << Set Items(lstNew)			
			)
		)
	)
)

The script associated with the Text Edit Box gets executed when you type a search string and press enter which I find more ergonomical than having to click a button but the same script could be attach to a button box.

 

Some complexity you need to think about:

  • What happens if a second search is performed - does it search the search results or the original list?  I find it helpful to provide a reset button to restore the original list.
  • Scoping of variables - in particular you need to make sure that the variable lst is still defined when the button is clicked.  I usually put my variables in explicit namespaces but if you follow the convention of "Names Default To Here(1) " then you can use the notation here:lst.
-Dave
jade

Contributor

Joined:

Apr 22, 2017

Thanks @David_Burnham
It's really more ergonomical than having to click a search button.

Actually my initial UI is by using the combo box, but now i want try to add the text edit box at below which can search the item in order for user to easy find the item rather than the user scroll down to check item one by one.

I had face one problem now which is when i run my whole script, it show me out this error:
Name Unresolved: HList in access or evaluation of 'HList' , HList( Button( "OK" ), Button( "Cancel" ) ) /*###*/

 

 

pmroz

Super User

Joined:

Jun 23, 2011

It is not recommended to use DIALOG() anymore.  Instead use NEW WINDOW().  Unfortunately most objects have different names in the two platforms.  For example HLIST and VLIST are part of DIALOG, whereas NEW WINDOW uses HLISTBOX and VLISTBOX.

 

The good news is that the scripting index covers all dialog box objects with lots of examples.

 

One final note - to have a modal box with NEW WINDOW you need to include << modal().

jade

Contributor

Joined:

Apr 22, 2017

So your meant is I totally cannot use the dialog box?
Therefore, if need to overcome my problem, i have to use the modal box instead of dialog box?
Because now i consider is if i change dialog box to use the modal box, all the code i need to change to modal box also.Because all the file that i have is all using dialog box, and all the file are link together.
You all answer is much appreciate.
Thanks.

ian_jmp

Staff

Joined:

Jun 23, 2011

To use the jargon, 'Dialog()' has been deprecated.

 

The phrase 'will not run in the future' is a little vague, but you are strongly advised to make the switch to 'New Window("Title", << modal)' now, particularly if you are developing a code base that you and others need to depend on.

 

How much work is involved in making the switch will dpend a little on how much code there is, and how you have structured and modularised it. Generally, when writing code, maintainability (or lack of it) is an important consideration, and JSL supports all the design patterns for you to do it right first time (though it's often the second time when you are learning!). There's a lot of useful information here.

jade

Contributor

Joined:

Apr 22, 2017

Thanks for the information
I will apply it into the script.