• About
    • Blog
    • Business Process
    • Charity Work
    • History
    • News
  • Services
    • Legacy System Support
    • Bespoke System Development
    • Web Design & Development
    • View all services
  • Products
  • Our work
    • Customers
    • Case Studies
  • Careers
  • Contact
Microsoft Partner - Application Development
6th March 2015

DevExpress – Run Report Straight From Navigation

DevExpress PSP Knowledge
DevExpress – Run Report Straight From Navigation

As described in one of my previous DevExpress articles, it is possible to open a detail view straight from the navigation menu while loading the relevant record to be displayed, this is useful for tables which will only ever contain one record e.g. System Configuration records which can never be created or deleted and there will only ever be one record making the list view unnecessary.

The above method and logic is also available for running reports straight from the navigation or from an action button placed within a toolbar. The following code below is an adaptation of the code in the previous article however it will allow you to run a DevExpress V2 Report which is stored within the database straight from a navigation item when clicked. I have also added some error handling in the form of a User Friendly Exception, which will be thrown if the report could not be found within the database, which will be a more user friendly error than the standard “Object Reference Error”.

using System;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.ReportsV2;
using DevExpress.ExpressApp.SystemModule;
using DevExpress.Persistent.BaseImpl;
 
/// <summary>
/// Navigation Window Controller
/// </summary>
public partial class NavigationWindowController : WindowController

/// <summary> /// Initializes a new instance of the <see cref="NavigationWindowController"/> class. /// </summary> public NavigationWindowController()

this.TargetWindowType = WindowType.Main;

/// <summary> /// Called when [activated]. /// </summary> protected override void OnActivated()

base.OnActivated(); Frame.GetController<ShowNavigationItemController>().CustomShowNavigationItem += new EventHandler<CustomShowNavigationItemEventArgs>(this.Report_CustomShowNavigationItem);

/// <summary> /// Called when [deactivated]. /// </summary> protected override void OnDeactivated()

base.OnDeactivated(); Frame.GetController<ShowNavigationItemController>().CustomShowNavigationItem -= new EventHandler<CustomShowNavigationItemEventArgs>(this.Report_CustomShowNavigationItem);

/// <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 Report_CustomShowNavigationItem(object sender, CustomShowNavigationItemEventArgs e)

if (e.ActionArguments.SelectedChoiceActionItem.Id == "NavigationItemIdHere")

IObjectSpace objectSpace = Application.CreateObjectSpace(); ReportDataV2 report = objectSpace.FindObject<ReportDataV2>(CriteriaOperator.Parse("DisplayName = 'Report name Here'")); if (report != null)

string handle = ReportDataProvider.ReportsStorage.GetReportContainerHandle(report); Frame.GetController<ReportServiceController>().ShowPreview(handle); e.Handled = true;

else

throw new UserFriendlyException("The report could not be found, please contact your system administrator.");

Share:
PSP IT Design & Development
About Us
  • Privacy Policy
  • History
  • Customers
  • News
  • Blogs
Services
  • Legacy System Modernisation
  • Website Design & Development
  • Bespoke Application Development
  • Outsource IT Strategy
  • All Services
Contact
  • 01775 722377
  • letstalk@psp-it.co.uk
  • Carver House, Apex Court, Spalding Office Park, Elsoms Way, Pinchbeck, Spalding,Lincolnshire, PE11 3UL

Terms & Conditions Privacy Policy

© PSP People Systems Process Ltd. 2022. All Rights Reserved.

MENU

MENU

  • About

    • Blog

    • Business Process

    • Charity Work

    • History

    • News

  • Services

    • Legacy System Support

    • Bespoke System Development

    • Web Design & Development

    • View all services

  • Products

  • Our work

    • Customers

    • Case Studies

  • Careers

  • Contact

© PSP People Systems Process Ltd. 2022. All Rights Reserved. Privacy Policy

give us a call
01775 722377
drop us an email