Share via


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

In Microsoft Dynamics NAV 2013, creating new reports is divided into the following 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 modify the visual layout of a report.

About This Walkthrough

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 and adding an image 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 how to design the layout of a report by using Visual Studio, see Defining a Report Layout (Visual Studio Report Designer).

Prerequisites

To complete this walkthrough, you will need:

  • Microsoft Dynamics NAV with a developer license.

  • The CRONUS International Ltd. demo data company.

  • Visual Studio. For more information about versions of Visual Studio that you can use, see System Requirements for Microsoft Dynamics NAV 2013. This walkthrough assumes that you are using Microsoft Visual Studio 2010.

Defining the Data Model

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 Microsoft Dynamics NAV Development Environment, on the Tools menu, choose Object Designer.

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

  3. In the first row, in the Data Source field, choose the AssistEdit button. In the Table List window, select the Item table (Table ID 27), and then choose the OK button.

  4. Verify that the Data Type column is set to DataItem, and then choose the OK button.

  5. On the View menu, choose Field Menu.

  6. In the Field Menu window, select the No., Description, and Picture fields, and then choose the OK button.

  7. When prompted to add these fields, choose Yes.

  8. In the Save AS dialog box, in the ID field, enter 50000, and then in the Name text box, enter ItemReport.

  9. Make sure Compile is selected, and then choose the OK button.

Designing the Report Layout and Adding an Image

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 and add an image in Visual Studio

  1. In the Object Designer, select the ItemReport that you created, and then choose Design.

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

  3. In Visual Studio, on the View menu, choose Toolbox to open the toolbox.

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

  5. On the View menu, choose Report Data. The Report Data window opens.

  6. From the Report Data window, under DataSource, and under DataSet_Result, drag the No_Item field to the first column, second row of the table in the Data section of the report layout.

  7. Under Data Sources, and under DataSet_Result, drag the Description_Item field to the second column, second row of the table in the Data section.

  8. From the Toolbox, drag an Image control to the third column, second row of the table. The Image Properties window opens.

  9. In the Image Properties window, set the following properties.

    Property Setting

    Source (On the General tab, under Select the image source)

    Database

    Value (On the General tab, under Use this field)

    [Picture_Item]

    Dd301353.note(en-us,NAV.70).gifNote
    This is the Name of the Item.Picture column in Report Dataset Designer.

    MIMEType (On the General tab, under Use this MIME Type)

    image\bmp

    Note

    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.

  10. Choose ƒx to open the expression window for the picture field and then verify that the Set expression for: value text box contains the following value: =Fields!Picture_Item.Value. Choose the OK button to close the windows.

  11. (Optional) Resize the data row of the table to the appropriate size for the pictures.

  12. In the third column, first row of the table, enter Picture. This is the caption of the column.

  13. In the File menu, choose Save Report.rdlc, and then close Visual studio.

Synchronizing and Running the Report

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 development environment, close ItemReport in Report Dataset Designer. A message informs you that the .rdlc file for this report has changed and asks if you want to load the changes. Choose Yes to save the changes in the database.

  2. In the Save Changes window, make sure Compile is selected and then choose Yes to save the report.

  3. In the Object Designer, select the report (50000) and choose Run.

  4. Choose Preview to view the report. The report displays all in the items table.

  5. Close the report and run the report again.

  6. You can filter the report to only view items that have a picture associated with them by setting a filter for picture field.

    In the Edit-Item Report window, under Show results, choose Add Filter. In the Where drop-down list box, select Picture, and in the Enter Value text box, enter 1. Choose Preview. Now, only items that have pictures are displayed.

  7. Close the report.

Setting Up Interactive Sorting and Visibility Toggle

Now you will add interactive sorting to the ItemReport. Interactive sorting will enable 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 and visibility toggle

  1. In the development environment, in Object Designer, select the ItemReport report and then choose Design to open it in Report Dataset Designer.

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

  3. Select the No Item text box in the first row, first column, open the shortcut menu, and then choose Text Box Properties.

  4. In the Text Box Properties window, choose the Interactive Sorting tab.

  5. Under Change interactive sort options for text box, select the Enable interactive sort action for this text box check box.

  6. In the Sort by drop-down list box, select [No_Item] from the list, choose ƒx to open the expression window, and then verify that the Set expression for: SortExpression text box contains the following value: =Fields!No.Item.Value. Choose the OK button.

  7. Choose OK to close the Change interactive sort options for this text box window.

  8. Select the Description_Item text box in the first row, second column, open the shortcut menu, and then choose Text Box Properties.

  9. In the Text Box Properties window, choose the Interactive Sorting tab.

  10. Under Change interactive sort options for text box, select the Enable interactive sort action for this text box check box.

  11. In the Sort by drop-down list box, select [Description_Item] from the list, choose ƒx to open the Expression window, and then verify that the Set expression for: SortExpression text contains the following value: =Fields!Description_Item.Value. Choose the OK button.

  12. Choose OK to close the Text Box Properties window.

  13. Open the shortcut menu for the Image field in the second row, third column, and select Image Properties.

  14. In the Image Properties window, choose the Visibility tab, and then select the Display can be toggled by this report item check box.

  15. In the Display can be toggled by this report item drop-down list, select Textbox1, and then choose the OK button.

  16. On the File menu, choose Save Report.rdlc and close Visual Studio.

Resynchronizing and Running the Report

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. Switch to the development environment.

  2. If the ItemReport report is open in Report Dataset Designer, then close it. A message informs you that the .rdlc file for this report has changed and asks if you want to load the changes. Choose Yes to save the changes in the database.

  3. In the Save Changes window, make sure Compile is selected and choose Yes to save the report.

  4. In Report Dataset Designer, on the Tools menu, choose Compile to compile the ItemReport.

  5. On the Windows taskbar, choose Start, and then choose Run.

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

  7. Choose Preview to view the report. You can use interactive sorting for the No Item and Description Item columns. You can also collapse each item hide the picture.

See Also

Other Resources

Report Design Walkthroughs