In this post we are going to learn how to make reports that have links in them.

As always, I start with some sample data. In this case, it will be a list of my favorite blogs.

 

START WITH THE DATA

First, I create a new Data Method

image

image

 

This is the source code for that Data Method

 

[DataMethod(), AxSessionPermission(SecurityAction.Assert)]
    public static System.Data.DataTable DataMethod1()
    {
        var favorite_blogs = new []
        {
            new {
                    Name="Visio Guy",
                    Url ="http://www.visguy.com/"},
            new {
                    Name="Greg's Cool [Insert Clever Name] of the Day",
                    Url ="http://coolthingoftheday.blogspot.com/"},
            new {
                    Name="DisplayBlog",
                    Url ="http://www.displayblog.com/"}

        };

        var datatable = Isotope.Data.DataUtil.DataTableFromEnumerable(favorite_blogs);
        return datatable;
    }

 

You can see from this example how easy it is to create a quick dataset via anonymous types.

 

And then create a new Data set …

 

image

And set the properties as appropriate to point to the Data Method

 

image

CREATE A DESIGN

Now just drag the Data Set into the Designs node and assign some style templates and preview…

image

The column layout isn’t perfect (we’ll correct that later).

So far what we have is just text. If you move the mouse over the URLs they are not treated as URLs but plain text. You can see from the screenshot below that although the cursor is right over the URL that the mouse retains it’s Arrow shape which indicates that this is just plain text.

 

image

Our next step will be to make them clickable.

 

ADD A URL DRILL THROUGH ACTION

 

Expand the design and find the Data > Url field and right click and select URL Drill Through Action

 

 

image

A new node will appear …

image

Examine its properties. We need to set the Expression value to something useful.

 

image

Click on that field and select “=Fields!Url.Value”

image

image

 

 

Now preview the report and move the mouse over a URL

image

As you can see, the cursor now has a hand shape. If you click a new window will launch to that URL

image

 

image

 

At this point we have the basics done. Let’s optimize the report.

 

HIDING THE RAW URLS

We don’t want to show the URLs in the report – we want the user to click on the NAME of the blog and that should go to the appropriate URL. This is simple to achieve.

Delete the Url from the design

image

Only the Name field will remain in the design. Right-Click on the Name field and add a URL Drill Through Action

 

image

You can see the new node is created.

image  

Examine its properties. And set the Expression value to =Fields!Url.Value

image

The thing to notice here is that although the Url field has been deleted from the design (what is shown) of the report, the Url field from the data set that is bound to the report.

Now preview the report

image

 

As expected there is only one column. The URLs are not visible.

 

Now move the mouse cursor over on of the links…

 

image

 

And click…

 

image

Perfect. the link now goes to the correct place.

 

IMPROVING THE LAYOUT

Let’s make the Name column wide enough so that the blog names don’t span multiple lines.

Select the Name column.

image

And examine its properties. You can see that the Display Width property controls the width of the column

image 

Let’s change this to 4 inches

 

  image

And preview the report.

 

image

 

LINKS THAT LOOK LIKE LINKS

One final problem remains: Although the links work – they don’t look like links. They still look like plain text.

A straightforward way of fixing this problem is to again look at the properties of the Name field. There’s a section called Style

image 

If you expand that node … you can see there are more options available.

image

Also, you’ll notice the button on the right with the ellipsis. Click on that.

 

image

And you’ll get a special dialog called the Cell Style editor

 

image

 

Set the color to Blue

image

And the Decoration to Underline

image 

And click OK.

Now preview the report.

image

Done. We have a report that has simple clickable links.

 

SOURCE CODE

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