🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Column
This page was created by Stephanie on 2024-05-17. Last edited by Wikiadmin on 2026-07-29.

A column is a named value in an MDriven ViewModel or a database table; use columns to present, edit, format, or supply supporting data for an application.

What a column represents

In a data model, an attribute represents one property of an entity. When the model is persisted to a database, such attributes are represented as columns in the corresponding database table.

For example, a customer can have attributes such as:

Entity Example attributes or columns
Customer CustomerID, Name, Email, Phone
Product ProductID, Name, Price, Category

Each column holds one value for a record. For example, the Email column for one customer can contain ada@example.com.

Columns in a ViewModel

A ViewModel column is a named value made available to the user interface. It can represent data that users see or edit, or it can provide information that controls how another column is rendered.

For example, a ViewModel can expose a Email column as an input. It can also include supporting columns such as Email_HelperText and Email_Placeholder. These supporting columns let the UI provide guidance without making the guidance part of the email value.

Use clear, consistent names. Several UI features identify a related column from its name and require the related columns to be on the same ViewModel nesting.

Configure data-entry columns

Configure the column that holds the value according to the data your application needs. Input controls render differently depending on the value type.

For text inputs, you can set the Texttype tagged value on the ViewModel column to request a browser input type such as Password, Email, Tel, URL, or Search.

For example, set Texttype to Email on an Email ViewModel column when the value is an email address. See Documentation:Input Controls for helper text, placeholders, text types, and input icons.

Add presentation data with related columns

You can add columns that provide presentation data for another ViewModel column. Keep these columns on the same nesting as the column they affect. Mark a formatting-only column as not visible when it should not appear as a separate UI field.

Goal Naming pattern Example More information
Show helper text below an input <ViewModelColumn>_HelperText Email_HelperText Documentation:Input Controls
Show placeholder text for an empty input <ViewModelColumn>_Placeholder Email_Placeholder Documentation:Input Controls
Supply a label for a widget or button <ColumnName>_Label Save_Label Documentation:Databind labels in ViewModels
Supply a grid column header label <GridRootColumnName>_<GridColumnName>_Label Customers_Email_Label Documentation:Databind labels in ViewModels
Apply a style to a grid or table column <ColumnName>_Style Price_Style Documentation:Table Grid Column Style

Use columns for file downloads

A ViewModel column can hold file content and be rendered as a download link when it has the BlobDownloadLink=true tag.

For a data column named InvoiceFile, add these string columns on the same ViewModel nesting when needed:

  • InvoiceFile_ContentType supplies the response content type.
  • InvoiceFile_FileName supplies the downloaded attachment file name. The _FileName suffix is case-sensitive.

See HowTos:Using BlobDownloadLink for the complete download behavior and requirements.

Render HTML from a column carefully

A column tagged with DataIsHtml can supply HTML that the page uses directly as HTML. For example, a column can point to a Blob field containing administrator-authored content, or to HTML produced by an HTML report. Because the content is used directly in the page, use this option only when the column is intended to contain HTML. See Documentation:Column.DataIsHtml.

Column layout in grid ViewModels

In Grid mode, the ViewModel has settings for the number of columns and rows, column width, and row height. Column width and row height affect the designer and provide default minimum sizes in the running application; CSS can override these values in a web application. A width or height of <= 1 prevents generation of the corresponding minimum-size style. See Documentation:ViewModel settings.

Persisted database columns

Database engines can place limits on schema changes. In particular, SQLite does not support dropping a column one by one. MDriven handles this case by recreating the table through its SQLite persistence configuration. If you use SQLite and remove a persisted attribute, review Documentation:SQLite before applying the schema change.

See also

[[Category:Attributes and data types [Beginner]]]