cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
javier_guzman0
Level II

How to select rows in a JSL tablebox and assign them a specific color

I placed a tech support ticket to get the answer for this simple question, since there are no other post that are relevant to this issue. I decided to share the answer here with the JMP community so others could benefit as well:

My Question:

If it’s possible, I would like to know if I can perform the following on a TableBox:

GuiWindow = NewWindow("SMS1");

theBox = TableBox(

stringColBox("State",{"Florida", "Texas", "Main", "California"}), 

NumberColBox("Width",{45,66,88,13}),

NumberColBox("Length",{67,34,1,78}),

NumberColBox("Depth",{13,65,32,56}));

theBox << Set Selectable Rows(1);

GuiWindow << Append(theBox);

  1. Select a row in a TableBox that meets the following criteria: column Length is larger than Column Depth
    1. In this example, the selected rows should be: Row 1 (Florida) and Row 4 (California)
  2. Change the row color to Red.

Tech support answer (Thanks Marcos!)

GuiWindow = NewWindow("SMS1");

theBox = TableBox(

stringColBox("State",{"Florida", "Texas", "Main", "California"}), 

NumberColBox("Width",{45,66,88,13}),

NumberColBox("Length",{67,34,1,78}),

NumberColBox("Depth",{13,65,32,56}));

theBox << Set Selectable Rows(1);

GuiWindow << Append(theBox);

    dt = theBox << Make into Data Table( invisible );

    rs = dt << Get Rows Where( :Length > :Depth );

    theBox << Set Selected Rows( rs );

    theBox << Set Selected Row Color( "red" );

  I hope this helps.  Please let me know what other questions you have.

  Regards

   Marcos

1 ACCEPTED SOLUTION

Accepted Solutions
Duane_Hayes
Staff (Retired)

Re: How to select rows in a JSL tablebox and assign them a specific color

Tech support answer (Thanks Marcos!)

 

GuiWindow = NewWindow("SMS1");

theBox = TableBox(

stringColBox("State",{"Florida", "Texas", "Main", "California"}), 

NumberColBox("Width",{45,66,88,13}),

NumberColBox("Length",{67,34,1,78}),

NumberColBox("Depth",{13,65,32,56}));

theBox << Set Selectable Rows(1);

GuiWindow << Append(theBox);

 

    dt = theBox << Make into Data Table( invisible );

    rs = dt << Get Rows Where( :Length > :Depth );

    theBox << Set Selected Rows( rs );

    theBox << Set Selected Row Color( "red" );

 

  I hope this helps.  Please let me know what other questions you have.

  Regards

   Marcos

Duane Hayes

View solution in original post

3 REPLIES 3

Re: How to select rows in a JSL tablebox and assign them a specific color

This script leaves the table box open to further selection by the user as far as it goes. If all you want to do is highlight particular cases in the table, then follow with this message:

theBox << Set Selectable Rows( 0 );

You won't lose the coloring.

javier_guzman0
Level II

Re: How to select rows in a JSL tablebox and assign them a specific color

Hi Mark,

I tried your suggestion, but I lose the coloring in the process. Here is the behavior that I'm noticing, let me know you can reproduce it as well (I'm using JMP 11 Pro and Standard).

If I place the line 'theBox << Set Selectable Rows(0);' at the end, I lose the coloring (the rows are no longer selected).

    GuiWindow = NewWindow("SMS1");

    theBox = TableBox(

    stringColBox("State",{"Florida", "Texas", "Main", "California"}),

    NumberColBox("Width",{45,66,88,13}),

    NumberColBox("Length",{67,34,1,78}),

    NumberColBox("Depth",{13,65,32,56}));

    theBox << Set Selectable Rows(1);

    GuiWindow << Append(theBox);

    dt = theBox << Make into Data Table( invisible );

    rs = dt << Get Rows Where( :Length > :Depth );

    theBox << Set Selected Rows( rs );

    theBox << Set Selected Row Color( "red" );

    ​theBox << Set Selectable Rows(0);


If I place the line anywhere else after declaring the theBox object, the rows are selected, and colored as expected, but the user can select other rows, and thus change the initial output.

    GuiWindow = NewWindow("SMS1");

    theBox = TableBox(

    stringColBox("State",{"Florida", "Texas", "Main", "California"}),

    NumberColBox("Width",{45,66,88,13}),

    NumberColBox("Length",{67,34,1,78}),

    NumberColBox("Depth",{13,65,32,56}));

    theBox << Set Selectable Rows(1);

    GuiWindow << Append(theBox);

    ​theBox << Set Selectable Rows(0);

    dt = theBox << Make into Data Table( invisible );

    rs = dt << Get Rows Where( :Length > :Depth );

    theBox << Set Selected Rows( rs );

    theBox << Set Selected Row Color( "red" );

Duane_Hayes
Staff (Retired)

Re: How to select rows in a JSL tablebox and assign them a specific color

Tech support answer (Thanks Marcos!)

 

GuiWindow = NewWindow("SMS1");

theBox = TableBox(

stringColBox("State",{"Florida", "Texas", "Main", "California"}), 

NumberColBox("Width",{45,66,88,13}),

NumberColBox("Length",{67,34,1,78}),

NumberColBox("Depth",{13,65,32,56}));

theBox << Set Selectable Rows(1);

GuiWindow << Append(theBox);

 

    dt = theBox << Make into Data Table( invisible );

    rs = dt << Get Rows Where( :Length > :Depth );

    theBox << Set Selected Rows( rs );

    theBox << Set Selected Row Color( "red" );

 

  I hope this helps.  Please let me know what other questions you have.

  Regards

   Marcos

Duane Hayes