Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

Dynamically add archive columns at runtime?

Hi, 

when you make an Archive Provider (or an extender) you have to create the ArchiveColumnInfo definitions using the magical '_col' prefix, so that the reflection mechanism can find the columns.

I'd like to make a more dynamic provider, where I during development do not know which database fields exists. Typical example is for a provider to expose the fields from a Service-extratable.

Is there an alternative way to define the columns, without having to hardcode columns during development-time with the '_col' prefix?

RE: Dynamically add archive columns at runtime?

Hi Frode,

Nothing prevents you from overriding:
        public List<ArchiveColumnInfo> GetAvailableColumns()
and doing all the household yourself.
Use a ColumnHelper member to get some help...

I have also seen providers doing this by using ColumnHelper.AddAvailableColumns( searchColumns ) dynamically such as for FindErpProduct. Mostly this happens in the constructor based of on a second parameter for Extra context - so we get to the correct Connection/Connector plugin.

The challenge however is for the GUI control. In Win, when you use the so called Advanced find product search of the quote system, the GUI control knows it is a run-time provider type where available columns cannot be know at compile time. Since the meta data has no tag for default-show, the control will simply add the first 5 columns it finds from GetAvailableColumns(). Once the columns of such an archive has been otherwise configured, they will get restored as long as they are still part of the collection returned by GetAvilableColumns. I.o.w. using the CustomArchive system of Win with such a provider, the very first time all you will get are the 5 virtual columns for Entity Name, Primary Key, Rights, StyleHint, LinkHint - better than nothing! Last but not least, Win needs to know that these providers have dynamic columns to avoid caching and this is not a property of the provider API. Bottom line, if the columns are likely to change according to Current identity (e.g. ERP system), our CustomArchive control is going to fail.

Don't know how this works in Web. I expect you have a lot more control over this in Web so you are going to be in the clear!

Conrad

Af: Conrad Weyns 17. dec 2017

RE: Dynamically add archive columns at runtime?

Thanks, doing this seems to work.

ArchiveColumnInfo boolColumn = new ArchiveColumnInfo(
    "x_bool", 
    "My checkbox column", 
    "My tooltip", 
    Constants.DisplayTypes.Checkbox,
    true,
    true,
    ColumnHelper.DefaultCheckboxWidth,
    Constants.RestrictionTypes.Bool);

ColumnHelper.AddAvailableColumns(boolColumn);
Af: Frode Lillerud 22. jan 2018