15th September 2014

DevExpress - View Detail View Straight From Navigation

DevExpress - View Detail View Straight From Navigation

Many applications require a System Configuration record which contains all of the settings for the application, there will only ever be the need for one System Configuration record.  When a user wishes to view or edit this record, they can do easily and efficently, without the need to search a list of records.

The first step to alter this behaviour is to go into the Model and set the System Configurations navigation item View to Detail View, this will now open the System Configuration record straight away in detail view without viewing the list first. This can all be done in the platform antagonistic project so the implementation will work in both web and Windows without any bespoke coding for either platform.

Now it is required to implement a view controller to pass through the System Configuration record to the Detail View, to do this the code below will need to be implemented, the System Configuration class must use an internal construction for this method to work.

/// <summary>
/// Handles the CustomShowNavigationItem event of the SystemConfiguration control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="CustomShowNavigationItemEventArgs"/> instance containing the event data.</param>
private void SystemConfiguration_CustomShowNavigationItem(object sender, CustomShowNavigationItemEventArgs e)

IModelDetailView model = ((IModelNavigationItem)e.ActionArguments.SelectedChoiceActionItem.Model).View as IModelDetailView; if (model != null && model.Id == "SystemConfiguration_DetailView")

IObjectSpace objectSpace = Application.CreateObjectSpace(); SystemConfiguration systemConfigurationRecord = SystemConfiguration.GetInstance(objectSpace); e.ActionArguments.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpace, model, true, systemConfigurationRecord); e.ActionArguments.ShowViewParameters.TargetWindow = TargetWindow.Current; e.Handled = true;

Fill in this quick form and discover your digital future
Choose your interests:

Where to find us

We'd love to welcome you into our office! We're only 20 miles north of Peterborough, conveniently just off the A16.

Carver House
Apex Court, Elsoms Way
PE11 3UL