How to create a tabbed dialog

A tabbed dialog is a Site Manager dialog that has an embedded tab control object, in other words, a combination of a dialog and a tabbed view. It is usually used to add complex objects, for example a Retail Item.

Create the dialog

To create a tabbed dialog you can create a simple dialog as presented in How to create a dialog, in which you add a tab control.

Functions overview

Tabbed dialog functions

A list of commonly used functions when creating a tabbed dialog:

Base functions

Description

protected override void OnClosing

When closing the tabbed dialog we can call the tabSheetTabs.SaveUserInterface() method in case any tab needs to save something on the user interface.

void btnOK_Click

When we press OK, the data from all tabs is gathered and validated, then if everything is valid, we save the new object.

void btnCancel_Click

Closes a dialog and no data is changed.

protected override IApplicationCallbacks OnGetFramework()

Needs to return the Site Manager framework instance. This instance is usually kept in the: PluginEntry.Framework.

Tab functions

A list of commonly used functions when creating tab used in a tabbed dialog:

Base functions

Description

void LoadData(
bool isRevert,
RecordIdentifier context,
object internalContext)

The function is called by the tabbed dialog via the tabControl.SetData(..) function.

isRevert parameter is the same parameter as the tabbed dialog gets and indicates whether the user is reverting or not.

context parameter is usually the ID of the object that is being edited by the tabbed dialog.

internalContext is usually the data object that the tabbed dialog is editing.

Note that the text above describes the usual setup but that is not always the case. Sometimes we do not have a context we are working with and sometimes the internalContext parameter is more complex. You need to view the tabControl.SetData() function of the tabbed dialog to see what it is really sending.

void SaveSecondaryRecords()

This function is called by the tabControl.SaveSecondaryRecords() and can be used to save additional data after saving the main object.

object OnViewPageMessage(
object sender,
string message,
object param,
ref bool handled)

This function is called by the tab control via the tabControl.SendViewPageMessage(..) function.

All tabs registered to the tab control will receive the message and we can check for a particular message and execute some functionality based on each message.

void IDialogTabViewWithRequiredFields
.RequiredFieldsAreValid(
FieldValidationArguments args)

This function is called by the tab control via the tabControl.AllRequiredFieldsAreValid(..) function.

This function is used to validate the tab and return a validation result.

bool SaveData()

This function is called by the tabControl.GetData() which will populate the main object with all the properties from each tab, before the actual save can be made.

void GetAuditDescriptors(

List<AuditDescriptor> contexts)

Connects the tab with an audit view. See chapter 3.7 Auditing for more details.

void OnDataChanged(..)

This function is described in the different kinds of Site Manager views.
The only thing that is different here from the functionality in the views is that the tabbed views are responsible for forwarding the message that they get to the tabs. They do this through the tabSheetTabs.BroadcastChangeInformation(..) function. From this function the tabs of the view are called.

void OnClose()

This function is used to clear any data when the tab is discarded. Usually you can leave this empty.

Sample code walkthrough

Below we can see examples of the basic functions used in a tabbed dialog and tabs used in the dialog:

 

Next task is to exercise creating tabs: Lesson 5 - Plugins: views, tabs and dialogs