cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
JasonWS
Level II

Why can't I get CalendarBox values from inside an IfBox in a modal window?

I'm using JMP 19. I have a modal window with an interactive user interface. Inside that interface the user chooses some dates and I want to use those dates when they close the window. 

I can get the value of a RadioBox or a TextEditBox, so why does the CalendarBox show as Empty() when I try to get values from it?

QueryWindow = NewWindow("Query.jsl",
		<<Modal,
		<<Return Result,
		PanelBox("Test Data Query Builder",
			PanelBox("Database Info", TextBox("Connection Info", <<SetFontSize(6))),
			PanelBox("Date Range", 
						rb_DateOption = RadioBox({"From-To","From-to-Present","Wildcard"},<<SetFunction(
												Function({this},
													Sel1 = rb_DateOption << GetSelected();
													if_From << Set(Sel1 == "From-To"|Sel1 == "From-to-Present");
													if_To << Set(Sel1 == "From-To");
													if_cb << Set(Sel1 == "From-To"|Sel1 == "From-to-Present");
													))),
			LineupBox(NCol(2), if_From = IfBox(1,qw_From = CalendarBox(<<Date(Today()-In Days(180)), 
																	   <<Min Date(Parse Date("1/1/2000")), 
																	   <<Max Date(Today()-In Hours(12)),
																	   <<ShowTime(0)
																	   )
											   ), 
							   if_To = IfBox(1,qw_To = CalendarBox(<<Date(Today()), 
																   <<Min Date(qw_From), 
																   <<Max Date(Today()),
																   <<ShowTime(0)
																   )
											), 
							   if_cb = IfBox(1,TextBox("Dates are absolute in each time zone unless \!"To Present\!" is selected.",
										<<SetFontSize(8))),							   	
							   ),

			),
			PanelBox("Query Parameters",
				LineupBox(NCol(2), TextBox("Category        "), lb_Category = ListBox({"1","2"}, <<SetFontSize(8))),
				LineupBox(NCol(2), TextBox("Part Numbers"), tb_PartNums = TextEditBox("%", <<SetNLines(3), <<SetWidth(200))),
			),		
		)
	);
	
show(QueryWindow["tb_PartNums"]);
show(QueryWindow["rb_DateOption"]);
show(QueryWindow["qw_From"]);

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Why can't I get CalendarBox values from inside an IfBox in a modal window?

<< Return Result might not work with << Get Date which calendar box uses. Usually I don't rely just on << Return Result and I always add OK/Cancel buttons to Modal windows and when you do this, you can add << Get Date to the OK button for example



QueryWindow = New Window("Query.jsl",
	<<Modal,
	<<Return Result,
	Panel Box("Test Data Query Builder",
		Panel Box("Database Info", Text Box("Connection Info", <<SetFontSize(6))),
		Panel Box("Date Range",
			rb_DateOption = Radio Box(
				{"From-To", "From-to-Present", "Wildcard"},
				<<SetFunction(
					Function({this},
						Sel1 = rb_DateOption << GetSelected();
						if_From << Set(Sel1 == "From-To" | Sel1 == "From-to-Present");
						if_To << Set(Sel1 == "From-To");
						if_cb << Set(Sel1 == "From-To" | Sel1 == "From-to-Present");
					)
				)
			),
			Lineup Box(N Col(2),
				if_From = If Box(
					1,
					qw_From = Calendar Box(
						<<Date(Today() - In Days(180)),
						<<Min Date(Parse Date("1/1/2000")),
						<<Max Date(Today() - In Hours(12)),
						<<ShowTime(0)
					)
				),
				if_To = If Box(1, qw_To = Calendar Box(<<Date(Today()), <<Min Date(qw_From), <<Max Date(Today()), <<ShowTime(0))),
				if_cb = If Box(1, Text Box("Dates are absolute in each time zone unless \!"To Present\!" is selected.", <<SetFontSize(8))),

			), 

		),
		Panel Box("Query Parameters",
			Lineup Box(N Col(2), Text Box("Category        "), lb_Category = List Box({"1", "2"}, <<SetFontSize(8))),
			Lineup Box(N Col(2), Text Box("Part Numbers"), tb_PartNums = Text Edit Box("%", <<SetNLines(3), <<SetWidth(200))),

		),
		Panel Box("Actions",
			Lineup Box(N Col(2),
				Button Box("OK",
					to = qw_to << get date;
					from = qw_from << get date;
				),
				Button Box("Cancel")
			)
		)
	)
);
	
Show(QueryWindow["tb_PartNums"]);
Show(QueryWindow["rb_DateOption"]);
Show(QueryWindow["qw_From"]);
show(to, from);
-Jarmo

View solution in original post

5 REPLIES 5
Craige_Hales
Super User

Re: Why can't I get CalendarBox values from inside an IfBox in a modal window?

I have not studied this in a while, but it still seems to work Select Date Range with Calendar Boxes 

Craige
jthi
Super User

Re: Why can't I get CalendarBox values from inside an IfBox in a modal window?

<< Return Result might not work with << Get Date which calendar box uses. Usually I don't rely just on << Return Result and I always add OK/Cancel buttons to Modal windows and when you do this, you can add << Get Date to the OK button for example



QueryWindow = New Window("Query.jsl",
	<<Modal,
	<<Return Result,
	Panel Box("Test Data Query Builder",
		Panel Box("Database Info", Text Box("Connection Info", <<SetFontSize(6))),
		Panel Box("Date Range",
			rb_DateOption = Radio Box(
				{"From-To", "From-to-Present", "Wildcard"},
				<<SetFunction(
					Function({this},
						Sel1 = rb_DateOption << GetSelected();
						if_From << Set(Sel1 == "From-To" | Sel1 == "From-to-Present");
						if_To << Set(Sel1 == "From-To");
						if_cb << Set(Sel1 == "From-To" | Sel1 == "From-to-Present");
					)
				)
			),
			Lineup Box(N Col(2),
				if_From = If Box(
					1,
					qw_From = Calendar Box(
						<<Date(Today() - In Days(180)),
						<<Min Date(Parse Date("1/1/2000")),
						<<Max Date(Today() - In Hours(12)),
						<<ShowTime(0)
					)
				),
				if_To = If Box(1, qw_To = Calendar Box(<<Date(Today()), <<Min Date(qw_From), <<Max Date(Today()), <<ShowTime(0))),
				if_cb = If Box(1, Text Box("Dates are absolute in each time zone unless \!"To Present\!" is selected.", <<SetFontSize(8))),

			), 

		),
		Panel Box("Query Parameters",
			Lineup Box(N Col(2), Text Box("Category        "), lb_Category = List Box({"1", "2"}, <<SetFontSize(8))),
			Lineup Box(N Col(2), Text Box("Part Numbers"), tb_PartNums = Text Edit Box("%", <<SetNLines(3), <<SetWidth(200))),

		),
		Panel Box("Actions",
			Lineup Box(N Col(2),
				Button Box("OK",
					to = qw_to << get date;
					from = qw_from << get date;
				),
				Button Box("Cancel")
			)
		)
	)
);
	
Show(QueryWindow["tb_PartNums"]);
Show(QueryWindow["rb_DateOption"]);
Show(QueryWindow["qw_From"]);
show(to, from);
-Jarmo
JasonWS
Level II

Re: Why can't I get CalendarBox values from inside an IfBox in a modal window?

I really appreciate the answer. 

I was also able to do the same with OnValidate, though I would still like to know why the QueryWindow[] comes up as Empty(). I think that would help my understanding of what's preventing it from working both ways. 

jthi
Super User

Re: Why can't I get CalendarBox values from inside an IfBox in a modal window?

Did you verify that the issue is ifbox + calendar box?

Names Default To Here(1);

nw = New Window("Query.jsl",
	<<Modal,
	<<Return Result,
	cb1 = Calendar Box()
);

My guess is that << Return Result which you can use to get the results from Modal Window inputs doesn't just work with Calendar Box() so it will return Empty().

-Jarmo
JasonWS
Level II

Re: Why can't I get CalendarBox values from inside an IfBox in a modal window?

Oh, it didn't work either way, IfBox(CalendarBox()) or CalendarBox(). I had to use the buttons or OnValidate.

Recommended Articles