What happens when you need to include a column in your table that isn’t returned from your API? Maybe the column will consist of some information processed at runtime by existing data, such as a concatenation (first name and last name), or it may be conditional logic.

Simple concatenations can be included within your view’s table template, however there may be cases where the business logic is too complex for calculating this extra column, or the data may be coming from another service. In these scenarios its better to add an extra attribute to your model — a dynamic attribute. In ADF we used to call these transient attributes.

I came across this use case in a project that called out to a service to perform actions on one or more rows in a table. If this service failed to process the rows for any reason, I wanted to highlight the failed rows visually to the user.

In the example I describe below, the use case is stripped back, I am simply extending my model to include some conditional logic. If the conditional logic holds true, then we highlight the row in red by adding an extra attribute onto the JSON response and using that extra column to toggle the row colour.

Although a simple example, it is a good starting point for more complex scenarios.