Setting an Alias for object properties

Stimulsoft Reports.NET discussion
Post Reply
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Setting an Alias for object properties

Post by Tobias »

When registering a plain C# object as data source, is there a way to provide alias names for the properties?

e.g. having something like:

Code: Select all

public class ReportDataNode
{
    [StiAlias(I18N.Tr("Name"))]
    public string Name {get; set;}

    [StiAlias(I18N.Tr("Quantity"))]
    public string Quantity {get; set;}
}
...as you see, I would like to use aliases to provide translated column/field names, depending on the users locale.

I just stumbled upon an old thread, where Edward indicated that such functionality will be available after 2008.2, but I couldn't find a hint, how this was implemented.

Tobias
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Setting an Alias for object properties

Post by Jan »

Hello Tobias,

Please check build from 11 Jan. You can use Stimulsoft.Report.Dictionary.StiAliasAttribute.

Thank you.
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Setting an Alias for object properties

Post by Tobias »

Thanks!

But unfortunately, it only works partially. When having nested objects, the alias is not set for child objects.
See the example below.

On the "detailOnly" dataset everything is fine and DetailProperty gets an alias.
But on the "masterDetail" dataset, the alias of the DetailProperty was not set.

Besides this: In this build the preview tab in the designer is gone, I can only do a html preview.

Code: Select all

public class Master
{
    [StiAlias("MasterProperty Alias")]
    public int MasterProperty { get; set; }

    public IList Details { get; set; }
}

public class Detail
{
    [StiAlias("DetailProperty Alias")]
    public int DetailProperty { get; set; }
}

...
var report = new StiReport();

var detail = new ArrayList {new Detail()};
var masterDetail = new ArrayList()
{
    new Master { Details = new ArrayList { new Detail() } }
};
report.RegData("detailOnly", detail);
report.RegData("masterDetail", masterDetail);
report.Design();
...
Image
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Setting an Alias for object properties

Post by Edward »

Hi Tobias,

Ok, we will check everything and will let you know our results.

Thank you.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Setting an Alias for object properties

Post by Jan »

Hello Tobias,

Problem fixed. Please check build from 25 Jan.

Thank you.
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Setting an Alias for object properties

Post by Tobias »

Sorry, couldn't test it before today.

So far the StiAlias attribute seems to work fine.

Thanks a lot!
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Setting an Alias for object properties

Post by Edward »

Hi Tobias,

Please let us know if any help is required.

Thank you.
Post Reply