A new view column type is defined by an application when it needs to present either its own data or a dataset in a more complex manner. For example, it might need to display the comment count related to the current row. To achieve this, it needs to retrieve the shared X value for the row and query its tables for the related comment data. To define a view column type, create a class that inherits the ITfSpaceViewColumnTypeAddon
interface.
An important aspect is the data mapping definition, which maps column_names to aliases. This allows application-specific view components to be used with various datasets that have different column names.
Seed Project | GitHub |
namespace WebVella.Tefter.Seeds.Addons;
public class SampleViewColumnType : ITfSpaceViewColumnTypeAddon
{
public const string ID = "cbe7a847-72a5-4af5-af7f-98771e043f14";
public const string NAME = "Percent";
public const string DESCRIPTION = "displays percent based of value between 0 and specified in settings value";
public const string FLUENT_ICON_NAME = "PercentSymbol";
public const string ALIAS = "Value";
public Guid Id { get; init; } = new Guid(ID);
public string Name { get; init; } = NAME;
public string Description { get; init; } = DESCRIPTION;
public string FluentIconName { get; init; } = FLUENT_ICON_NAME;
public List<TfSpaceViewColumnAddonDataMapping> DataMapping { get; init; }
public Guid? DefaultComponentId { get; init; }
public List<Guid> SupportedComponents { get; set; } = new();
public List<string> FilterAliases { get; init; }
public List<string> SortAliases { get; init; }
public List<Guid> SupportedAddonTypes { get; init; } = new();
public SampleViewColumnType()
{
DataMapping = new List<TfSpaceViewColumnAddonDataMapping>
{
new TfSpaceViewColumnAddonDataMapping
{
Alias = ALIAS,
Description = "this column is compatible with all column types, but its intended use is with text",
SupportedDatabaseColumnTypes = new List<TfDatabaseColumnType> {
TfDatabaseColumnType.ShortText,
TfDatabaseColumnType.Text
}
}
};
FilterAliases = new List<string>() { ALIAS };
SortAliases = new List<string> { ALIAS };
DefaultComponentId = new Guid(SampleDisplayViewColumnComponent.ID);
}
}