Walkthrough: Designing a Report with Images, Interactive Sorting, and Visibility Toggle

In Microsoft Dynamics NAV 2009, the process of creating new reports is divided into three phases:

  • Defining the data model on which the report is based.

  • Defining grouping and totaling for the report.

  • Designing the visual layout of the report.

With Microsoft Dynamics NAV, you can use Visual Studio Report Designer to design and edit the visual layout of a report.

This walkthrough provides an overview of how to create a report that displays images, allows interactive sorting, and provides visibility toggling. This walkthrough illustrates the following tasks:

  • Defining the data model in Microsoft Dynamics NAV.

  • Designing the report layout using Visual Studio Report Designer.

  • Synchronizing the report layout with Microsoft Dynamics NAV and running the report.

  • Applying interactive sorting to the report layout using Visual Studio Report Designer.

  • Resynchronizing the report layout with Microsoft Dynamics NAV and running the report.

For more information about designing the layout of a report with Visual Studio, see Defining a Report Layout (Visual Studio Report Designer).

Prerequisites

To complete this walkthrough, you will need:

When you create a new report, you must define where the data that the report will display should come from. You define the data model in Microsoft Dynamics NAV.

To define the data model

  1. In the Classic client, on the Tools menu, click Object Designer.

  2. In Object Designer, click Report, and then click New to open the New Report window.

  3. In the Table field, click the drop-down arrow, and then select the Item table with ID 27 in the Table List window.

  4. Select Create a blank report, and then click OK. The Report Designer window opens.

  5. In the DataItem field, select the Item table from the Table list, and then click OK.

  6. On the View menu, click Sections to open Section Designer.

  7. On the View menu, click Field Menu.

  8. In the Field Menu window, select the No., Description, and Picture fields. Click on the design area twice to add the fields.

  9. Close the windows, and then click Yes to save the report.

  10. In the ID field, enter 50000, and name the report ItemReport.

  11. Click OK.

Now that you have defined the data model for the report in Microsoft Dynamics NAV, you can design and refine the layout in Visual Studio.

To design the report layout in Visual Studio

  1. In the Classic client, select the ItemReport that you created, and then click Design.

  2. On the View menu, click Layout. The report opens in Visual Studio. The report layout is empty.

  3. In Visual Studio, on the View menu, click Toolbox.

  4. From the Toolbox, drag a Table to the report.

  5. On the Data menu, click Show Data Sources.

  6. From Data Sources, drag the Item_No_Caption field to the first column, first row of the table in the Header section of the report layout. Then drag the Item_No field to the first column, second row of the table in the Detail section of the report layout.

  7. From Data Sources, drag the Item_DescriptionCaption field to the second column, first row of the table in the Header section. Then drag the Item_Description field to the second column, second row of the table in the Detail section.

  8. From Data Sources, drag the Item_PictureCaption field to the third column, first row of the table in the Header section.

  9. From the Toolbox, drag an Image to the third column, second row of the table in the Detail section.

  10. On the View menu, click Properties Window.

  11. In the Properties window, set the following properties.

    NoteNote

    When you set the Source property, the items in the MIMEType drop-down list change. You must set the Source property to Database so that the image/bmp value is available in the MIMEType drop-down list.

    Property Setting

    Source

    Database

    MIMEType

    Image\bmp

    Value

    =Fields!Item_Picture.Value

  12. In the File menu, click Save Report.rdlc.

Now you will load the changes that you made in Visual Studio to Microsoft Dynamics NAV to synchronize the two versions of the ItemReport.

To synchronize and run the report

  1. In the Classic client, open ItemReport in Report Designer. A message informs you that the .rdlc file for this report has changed and asks if you want to load the changes. Click Yes to save the changes in the database.

  2. On the Tools menu, click Compile to compile the ItemReport.

  3. On the Windows taskbar, click Start, and then click Run.

  4. In the Run window, enter the following text: DynamicsNAV:////runreport?report=50000, and then click OK.

  5. Click Preview to view the report.

  6. Close the report and run the report again with filter Picture set to 1. Only items that have associated pictures are printed.

  7. Close the report.

The report now displays a list of items with a description and a picture of the item. You can filter the report to only view items that have a picture associated with them, as shown in step 6 in the preceding section. Now you will add interactive sorting to the ItemReport. Interactive sorting will allow users to interactively change the sort order for the data columns. By using the sort control button in the column header on the report, the user can change the sort order between ascending and descending.

To set up interactive sorting

  1. In the Classic client, open the ItemReport in Report Designer.

  2. On the View menu, click Layout. The report opens in Visual Studio.

  3. Right-click the Item_No_Caption field, and then click Properties.

  4. In the Properties window, click the Interactive Sort tab.

  5. On the Interactive Sort tab, select the Add an interactive sort action to this textbox field.

  6. In the Sort expression: field, select the expression =Fields!Item_No_.Value from the list, and then click OK.

  7. Right-click the Item_DescriptionCaption header, and then click Properties.

  8. In the Properties window, click the Interactive Sort tab.

  9. On the Interactive Sort tab, select the Add an interactive sort action to this textbox field.

  10. In the Sort expression: field, select the expression =Fields!Item_Description.Value, and then click OK.

  11. Right-click the Image field, and then click Properties.

  12. In the Properties window, click the Visibility tab, and then select the Visibility can be toggled by another report item field.

  13. In the Report item: field, select Item_No_Caption, and then click OK.

  14. In the File menu, click Save Report.rdlc.

After you have applied the latest changes to the report in Visual Studio, you will load the changes that you made in Microsoft Dynamics NAV to synchronize the two versions of the ItemReport. After the changes have been loaded, you can run the report to see the interactive sorting functionality.

To resynchronize and run the report

  1. In the Classic client, open the ItemReport in Report Designer. A message informs you that the .rdlc file for this report has changed and asks if you want to load the changes. Click Yes to save the changes in the database.

  2. On the Tools menu, click Compile to compile the ItemReport.

  3. On the Windows taskbar, click Start, and then click Run.

  4. In the Run window, enter the following text: DynamicsNAV:////runreport?report=50000, and then click OK.

  5. Click Preview to view the report. You can use interactive sorting for the No. and Description columns. You can also collapse the list and display the No. and Description columns without pictures.

Community Additions

ADD
Show: