How To Call the Xbasic UI from Working Preview in a Grid or UX Component

This technique only works in Desktop Applications.

Description

Learn how to call Xbasic in a UX or Grid component from working preview or opened in a window in a Desktop application.

Discussion

When you run a Grid or UX on the desktop, (which is equivalent to running in Working Preview mode), you might want to call Xbasic UI commands to respond to actions on the Grid and UX component. For example, you might have some Xbasic UDF that opens an Xdialog and you would like to call this Xbasic function when the user clicks a button on the Grid or UX.

Keep in mind that when a user clicks a button on the Grid or UX, the event handler for this click is Javascript code.

The Grid and UX both automatically define a Javascript function called 'genericXbasicUIFromWorkingPreview()' which can be used to invoke your Xbasic function.

For example, say that your Xbasic function (that displays an Xdialog) is called 'showXdialog()' and that it takes a single argument.

You might call this function as follows:

showXdialog("something to show");

To call this function from your Javascript code (only in Working Preview mode, of course), you would set the onClick event for the button to:

genericXbasicUIFromWorkingPreview('showxdialog("something to show")');

This technique can also be used to invoke other Xbasic functions that open a window. For example:

genericXbasicUIFromWorkingPreview('ui_msg_box("title","This is an Xdialog popup window.")');

Limitations

Desktop Applications Only