cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Thomas1
Level V

Select specific columns with JSL name contains code

The Name contains script:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Filter Col Selector Example",
    fontobj = lb = Filter Col Selector( width( 250 ) )
);
lb << Name contains( "a" );

 

delviers all colums, which contains a. What code must be added in order to mark one of these columns by clicking or double clikking the column from the list box?

 

3 ACCEPTED SOLUTIONS

Accepted Solutions
ian_jmp
Level X

Re: Select specific columns with JSL name contains code

Not sure I have understood correctly, but is this what you are after?

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// Make a FilterBoxSelector
New Window( "Filter Col Selector Example", lb = Filter Col Selector( width( 250 ) ));

// Define and set an 'action' script
actionScript =
Expr(
	selected = lb << getSelected;
	dt << clearColumnSelection;
	dt << selectColumns(selected);
);
lb << setScript(actionScript);

// Try it out
lb << Name contains("sex");
Wait(3);
lb << Name contains("eight");

View solution in original post

gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

This script works in JMP 12 and JMP 13. The reason the previous script does not work in earlier versions of JMP is that the data table messages clear column selections and select columns(list)  are not available. In earlier versions, columns need to be selected and unselected one at a time, hence, the required changes below. I do not have access to any version earlier than JMP 12.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );


New Window( "Filter Col Selector Example",
    fcb = Filter Col Selector( width( 250 ))
);

ib = (fcb<<Parent) << Xpath("//IfBox");
ib << set(1);
lbb = (fcb<<Parent) << Xpath("(//ListBoxBox)[1]");

lbb << set Function(Function({this},{_xx, i},
   selCol = this<<get selected;
   _xx = dt << get selected columns;
   For(i=1, i<=nitems(_xx), i++, _xx[i] << set selected(0));
   For(i=1, i<=nitems(selCol), i++, column(dt,selCol[i] ) << set selected(1));
  )	
);

 

View solution in original post

Thomas1
Level V

Re: Select specific columns with JSL name contains code

Perfect!

Now the JSL is working as it was intended. This makes things much easier. Thanks again.

View solution in original post

23 REPLIES 23
gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

Try this

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Filter Col Selector Example",
    fontobj = lb = Filter Col Selector( width( 250 ) )
);
lb << Name contains( "a" );

//select name

_xx = lb << get items;
_idx = Contains(_xx, "name");
lb << set selected( _idx, 1);  //or 0 to unselect

To see the available messages for an object select Main Menu > Scripting Index > Display Box > FilterColSelector

Thomas1
Level V

Re: Select specific columns with JSL name contains code

Thanks for your reply. Unfortunately, I did not get the results with the JSL update. Right now, I do not know why.

What I actually want is to get a similar behavior like for Cols / Columns Viewer ... / Name Contains … in JMP.

 

In general, this is possible with the mentioned JSL code from the Scripting Index:

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

New Window( "Filter Col Selector Example",

       fontobj = lb = Filter Col Selector( width( 250 ) )

);

lb << Name contains( );

 

 

However after the search string has been run, I I’d like to mark the desired / selected column in the data table, by double click. This part is still missing or not working within the JSL code from the Scripting Index.

ian_jmp
Level X

Re: Select specific columns with JSL name contains code

Not sure I have understood correctly, but is this what you are after?

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// Make a FilterBoxSelector
New Window( "Filter Col Selector Example", lb = Filter Col Selector( width( 250 ) ));

// Define and set an 'action' script
actionScript =
Expr(
	selected = lb << getSelected;
	dt << clearColumnSelection;
	dt << selectColumns(selected);
);
lb << setScript(actionScript);

// Try it out
lb << Name contains("sex");
Wait(3);
lb << Name contains("eight");
gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

Ian,

 

This is somewhat of a related question. Since the blogger response  had lb<< Name Contains(), I assumed, the request is for the user to enter a filter field and all columns would be selected.

 

So I tried to expose the Filter field (Show Filter). I failed at multiple attempts to enable this second menu item via JSL.

 

Is there a method to enable the filter field and configure the filter? I can get the PopupBox Menu Count, and Menu Text, but not the selection.

 

image.png

 

gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

Figured it out:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

New Window( "Filter Col Selector Example",
    fcb = Filter Col Selector( width( 250 ) )
);
ib = (fcb<<Parent) << Xpath("//IfBox");
ib << set(1);
Thomas1
Level V

Re: Select specific columns with JSL name contains code

Screenshot.JPG

Am I missing something. I can't get to selected column in the data table.

Thomas1
Level V

Re: Select specific columns with JSL name contains code

Thanks for your support Ian. It is not yet working as I want.

I' m looking for JSL code with which I can general search for specific columns by name ( part1) and then select the desired column in the list box from part1 by double clicking and mark the column in the data table.

The general search part1 is done with JSL code:

 

Names Default To Here( 1 );
dt = Current Data Table();
New Window( "Column Search",
	fontobj = lb = Filter Col Selector( width( 250 ) )
);
lb << Name contains(  );

The marking part2 could be done for the example like the code from the scripting index

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
dt << Go to( :BP 12F );

 

 How must they combined in order to find, mark and  go to the columns in a data table?

gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

Try this

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );


New Window( "Filter Col Selector Example",
    fcb = Filter Col Selector( width( 250 ))
);
ib = (fcb<<Parent) << Xpath("//IfBox");
ib << set(1);
lbb = (fcb<<Parent) << Xpath("(//ListBoxBox)[1]");
lbb << set Function(Function({this},
   selCol = this<<get selected;
   dt<<clear Column Selection;
   dt <<select Columns(selCol) ));
Thomas1
Level V

Re: Select specific columns with JSL name contains code

Thanks for your endurance. I really appreciate it. However the JSL is still not working as intended (see image).

 

The goal is to get the same function as one gets by using Cols /  Columns Viewer / Name  Contains. The results, which are being shown in the search box, can be clicked and as result, the specific column is selected in the origin data table.

 In case the proper JSL code is available, the whole column search / select process can be carried out much faster.

 

 

Screenshot1.JPG