Previously with Auto Design layouts, I left off with by saying that some required us to tweak the Datasets to get them to work. In this post, we’ll change the properties of the datasets and see how that enables the Matrix and chart layouts.

First, we need more data. I’ve revised the my Data Method to return more patient data …

using System;
using System.Collections.Generic;
using System.Security.Permissions;
using System.Data;
using System.Linq;

using Microsoft.Dynamics.Framework.Reports;
public partial class Report1
{

    [DataMethod(), AxSessionPermission(SecurityAction.Assert)]
    public static System.Data.DataTable DataMethod_Patient_Data()
    {
        int max_age = 60;
        int min_age = 18;

        int min_weight = 140; // weight in pounds
        int max_weight = 240;

        var areas = new[] { "Thoracic Surgery", "Emergency", "ENT" };
        var doctors = new [] { "Reddy", "Jackson", "Tordilla" };

        var r = new System.Random();
        var names = new string[] {      "Akuma", "Ryu", "Ken",
                                        "Guile", "M.Bison" ,
                                        "Chun-Li", "Cammy" ,
                                        "Blanka", "E.Honda",
                                        "Gen", "Birdie", "Adon",
                                        "Sagat", "Dhalsim", "Zangief",
                                        "Balrog", "Vega"};

        var records = from name in names
                      select new
                      {
                          Name = name,
                          Age = r.Next(min_age, max_age),
                          Weight = r.Next(min_weight, max_weight),
                          Area = areas[ r.Next(0, areas.Length) ],
                          Doctor = doctors [ r.Next(0, doctors.Length)] ,
                          Hypertension = (r.NextDouble() > 0.9) ? true : false,
                          Diabetes = (r.NextDouble() > 0.85) ? true : false,
                          Asthma = (r.NextDouble() > 0.75) ? true : false

                      };

        var datatable = Isotope.Data.DataUtil.DataTableFromEnumerable(records);

        return datatable;

    }

}

 

And then create a Data set that uses this Data method …

image

And when I drag it into the Designs node a new Design is created which I renamed to AutoDesign_Table_0 and set the styles for the layout and the table. The results are this.

image

Instead of modifying that Data set we will duplicate it using Copy

image

And then Paste

image

Which created this Dataset

image

And I will rename this to “Dataset_PatientData_1”

image

image

And set the Default layout to Matrix

image

And now drag it into the Designs node. A new AutoDesign is created. When you try to preview the design …

image

Obviously something is missing … let’s focus on the errors.

 

image

We obviously need to set something.

For this report, let’s say we want have a question about the number patients, we want to know who is treating them and what these patients are doing at the hospital.

In other words we want a matrix like this …

image

 

Go back to the dataset, click on Doctor and look at the properties for the field

image

The Grouping Type is set to category which is what we want

image

But the Field Type is set to Data. This we want to change.

image

We’ll set it to Grouping

image

OK, now the Doctor field is set up correctly.

image

After this modification, If we try to drag the dataset into a design and preview we’ll see …

image

This is better, now there’s only one error …

 

image

We are still missing column groupings.

We wanted the columns to be by “Area”, so let’s go to that field in the Data set

image

And examine it’s properties. Grouping Type is set to Category - we want to change this to Series

image

image

And Field type is set to Data. We’ll change this to Grouping.

image

image

Now the data set is ready.

image

Drag the dataset on to the Designs node and preview …

image

At least preview works.

But we need to fix this - we don’t want to see all the patient information, just the number of patients.

A simple way of fixing this up is expand the newly-created design

image

And then remove the data fields we don’t care about – just leave the Name field

image

If we drag preview the design now we will see …

image

Which is better.

Now we want to see the numbers of distinct patients, not their names.

So field the name field in the design.

image

And examine its properties. We are going to focus on the Aggregate Function from None

image

to CountDistinct

image

Now preview the report …

image

Almost what we want. But it looks ugly. Let’s set the style templates and see what happens.

image

Almost done.

Now we want to get rid of the “Name” on each column though.

image

Let’s look at the Name field in the design

image

And examine its properties. We will change it’s Caption property

image

by removing the expression and leaving it blank

image

Now preview the report…

image

Done.

 

SOURCE CODE

You can get it here: http://cid-19ec39cb500669d8.skydrive.live.com/browse.aspx/Public/Dev/SampleCode/Dynamics/SaveenR-Blog-Post-%7C52009-07-29%7C6?view=details