Back to Devexpress

Data Columns

aspnetmvc-115079-components-card-view-data-representation-basics-data-columns.md

latest9.5 KB
Original Source

Data Columns

  • Feb 02, 2023
  • 4 minutes to read

Data columns are used to display and edit data. CardView supports both bound and unbound data columns.

  • Bound data columns represent fields in CardView ‘s data source. Their CardViewColumn.FieldName properties refer to valid fields in a data source.
  • Unbound columns are not bound to any field in a data source. These columns must be populated manually. For information, see Unbound Columns.

There are fifteen types of server data columns.

Class NameDescription
CardViewBinaryImageColumnRepresents a data column used to display images from a binary stream.
CardViewButtonEditColumnRepresents a data column with the button editor.
CardViewCheckColumnRepresents a data column used to display and edit data from a Boolean data field.
CardViewColorEditColumnRepresents a data column used to display and edit color values.
CardViewComboBoxColumnRepresents a data column whose values are edited using the combo box editor.
CardViewDateColumnRepresents a data column used to display and edit data from a DateTime data field.
CardViewDropDownEditColumnRepresents a data column with an editor containing a customizable dropdown window.
CardViewHyperLinkColumnRepresents a data column with a hyperlink functionality.
CardViewImageColumnRepresents a data column used to display images from specified URLs.
CardViewMemoColumnRepresents a data column used to display and edit memo data.
CardViewProgressBarColumnRepresents a data column with the Progress Bar editor.
CardViewSpinEditColumnRepresents a data column used to display and edit numeric data.
CardViewTextColumnRepresents a data column used to display and edit text.
CardViewTimeEditColumnRepresents a data column used to display and edit time portions of DateTime values.
CardViewTokenBoxColumnA data column with the token box editor.

You can define the column type using the MVCxCardViewColumn.ColumnType property, which receives one of the MVCxCardViewColumnType enumeration values. The table below lists the CardView column types, and the default editors used to edit and display values in these column types.

Enum FieldDescriptionValues are Edited withValues are Displayed with
MVCxCardViewColumnType.BinaryImageIndicates that a binary image editor is used to display column values.Values are read-onlyBinaryImage
MVCxCardViewColumnType.ButtonEditIndicates that a button editor is used to edit column values.ButtonEditPlain text
MVCxCardViewColumnType.CheckBoxIndicates that a check box is used to edit and display column values.CheckBoxCheckBox
MVCxCardViewColumnType.ColorEditIndicates that a color editor is used to edit column values.ColorEditColor Indicator with plain text
MVCxCardViewColumnType.ComboBoxIndicates that a combo box is used to edit column values.ComboBoxPlain text
MVCxCardViewColumnType.DateEditIndicates that a date editor is used to edit column values.DateEditPlain text
MVCxCardViewColumnType.DropDownEditIndicates that a drop down editor is used to edit column values.DropDownEditPlain text
MVCxCardViewColumnType.HyperLinkIndicates that a hyperlink editor is used to display column values.TextBoxHyperLink
MVCxCardViewColumnType.ImageIndicates that an image editor is used to display column values.Values are read-onlyImage
MVCxCardViewColumnType.MemoIndicates that a memo editor is used to edit column values.MemoPlain text
MVCxCardViewColumnType.ProgressBarIndicates that a progress bar is used to visualize column values.SpinEditProgressBar
MVCxCardViewColumnType.SpinEditIndicates that a spin editor is used to edit column values.SpinEditPlain text
MVCxCardViewColumnType.TextBoxIndicates that a text box is used to edit column values.TextBoxPlain text
MVCxCardViewColumnType.TimeEditIndicates that a time editor is used to edit column values.TimeEditPlain text
MVCxCardViewColumnType.TokenBoxIndicates that a token box is used to edit column values.TokenBoxPlain text

On the client, data columns are represented by ASPxClientCardViewColumn objects.

Behavior

Since different types of data columns present different types of data, they provide their own editors. For example, boolean values are edited using a check box editor, while DateTime values are edited using a DateTime editor. To access and customize the column editor’s settings, use the CardViewColumn.PropertiesEdit property.

Data columns provide a set of boolean properties that enable you to specify which elements of a column’s functionality (sorting, filtering, etc.) are available to end-users. These options can be accessed using the CardViewColumn.Settings property.

To make a column read-only, set its CardViewColumn.ReadOnly property to true.

The code sample below demonstrates how to add a read-only data column, change columns settings, and change the built-in data editor settings.

csharp
@Html.DevExpress().CardView(settings => {
    settings.Name = "CardView";
    settings.CallbackRouteValues = new { Controller = "Home", Action = "CardViewPartial" };
    // ... 
    // Add a read-only data column. 
    settings.Columns.Add("FullName").ReadOnly = true;
    // Add a data column bound to the "Quantity" field. 
    settings.Columns.Add(c =>
    {
        // Define column settings. 
        // Define the name of the field to which the column is bound. 
        c.FieldName = "Quantity";
        // End-users will be able to edit column values using the SpinEdit extension. 
        c.ColumnType = MVCxCardViewColumnType.SpinEdit;
        // Define SpinEdit settings. 
        var spinSettings = (SpinEditProperties)c.PropertiesEdit;
        spinSettings.LargeIncrement = 10;
        spinSettings.SpinButtons.ShowLargeIncrementButtons = true;
    });
    // ... 
}).Bind(Model).GetHtml();

Visibility

The column’s visibility is specified by its WebColumnBase.Visible property. Its position among other visible columns is specified by its WebColumnBase.VisibleIndex property.