Custom select dialogs
You can create your own custom Select dialog to replace the standard Create Select Statement dialog that opens when clicking Select. In the QvFacebookConnector example, a custom Select dialog has been implemented and the button showing in the Script Editor has been labeled Metadata.
To create a custom select dialog, do the following:
- In your class extending QvxServer, override the method public override string CustomCaption to activate your custom button and set its name.
- In the same class, override the method public override string CreateSelectStatement(). The only requirement is that this method returns a script (for example, “SQL SELECT * FROM friends;”). In the QvFacebookConnector example, a dialog is launched. In the dialog, table selections can be made and then the dialog returns a script that is, in turn, returned to QlikView.
The following code example is taken straight from the file QvFacebookServer.cs in the QvFacebookConnector example:
/// <summary>
/// Set the label for the custom button in QlikView.
/// </summary>
public override string CustomCaption
{
get { return "Metadata..."; }
}
/// <summary>
/// Create the select statement.
/// </summary>
/// <returns>The select statement.</returns>
public override string CreateSelectStatement()
{
var metadataWindow = CreateSelectWindowHelper();
metadataWindow.ShowDialog();
string statement = null;
if (metadataWindow.DialogResult.Equals(true))
{
statement = metadataWindow.Statement;
}
return statement;
}
private QvSelectMetadataDialog CreateSelectWindowHelper()
{
// Since the owner of the metadataWindow is a Win32 process we need to
// use WindowInteropHelper to make it modal to its owner.
var metadataWindow = new QvSelectMetadataDialog();
var wih = new WindowInteropHelper(metadataWindow);
wih.Owner = MParentWindow;
return metadataWindow;
}