<%@ Page language="c#" AutoEventWireup="false" %> SandGrid Documentation

SandGrid User Guide

Specialised Columns

Back to Table of Contents

A number of specialised column classes exist in SandGrid. They all derive from GridColumn and are designed to either display specific datatypes or display interactive widgets in their cells.

GridColumn<T>

This generic column can be used with all the primitive .net types that implement IComparable<T> and its companion cell type is GridCell<T>. No special formatting is performed by the column, it is just intended to be used for strongly-typed data.

GridBooleanColumn

This column expects boolean data and its companion cell type is GridBooleanCell. Its default behaviour is to output the boolean value as text: "True" or "False". Its DisplayType property can be used to change the output to "Yes" and "No" and these textual values can be altered with the YesText and NoText properties. Alternatively the display type can be set to CheckMark, in which case a check mark is drawn if the value is true, and nothing is drawn otherwise. By customizing the YesText and NoText properties (which are localizable) you can quickly configure two alternative pieces of text to be displayed depending on a boolean value in your data.

GridButtonColumn

This column expects textual data and its companion cell type is GridButtonCell. The cell type must be used; this column type cannot interactively be used with virtual rows. The textual data is displayed as an interactive push button, styled to match the current Windows theme. An event is raised by the column itself when any button is clicked. A DrawButton property on the cell can be used to turn off a button for a particular cell.

GridHyperlinkColumn

This column expects textual data and its companion cell type is GridHyperlinkCell. The cell type must be used; this column type cannot interactively be used with virtual rows. The textual data is displayed as a hyperlink which is clickable. An event is raised by the column itself when any button is clicked. A DrawButton property on the cell can be used to turn off a hyperlink for a particular cell. Properties on the column control the link normal and hot colours.

GridDateTimeColumn

This column expects DateTime data and its companion cell type is GridDateTimeCell. It displays a DateTimePicker when its values are edited and knows how to intelligently group date values into useful groups such as Today, Yesterday, Last Week, etc.

GridConditionalImageColumn

This column expects boolean data and its companion cell type is GridBooleanCell. However it can accept any type that can be converted to boolean with Convert.ToBoolean, so an integer value will work. The column has two properties, TrueImage and FalseImage. Depending on the value in each row a different image is chosen. Either property can be null. This column is a great way of graphically depicting certain boolean conditions in your data.

GridProgressBarColumn

This column expects integer data and its companion cell type is GridIntegerCell. It draws a progress bar in each cell. Set the Minimum and Maximum values on the column itself, and for each cell whose value lies between these values a progress bar is drawn. Non-integer data or an integer lying outside the minimum and maximum values will result in no progress bar being drawn. A BarSize property can be used to change the size of the progress bar.

GridFileSizeColumn

This column expects long integer data and its companion cell type is GridCell<Int64>. It is designed especially for displaying file sizes. It formats the sizes into KB and displays them with that suffix. Also, it groups the values into Zero, Tiny, Small, Medium and Large categories in the same way Windows Explorer does. The text for these categories is of course localizable and the thresholds configurable.

GridForeignKeyColumn

This column expects any kind of data and is designed specifically for scenarios where DataSet is being used as a DataSource. By specifying the PrimaryKeyTable and ColumnName properties a foreign key encountered in data can be automatically looked up in a primary key table and a column in the primary key table can be used to display the data. This is great for situations where you have (for example) an integer employee ID but you want to display their name instead. This can be achieved with this column without even writing any code. A prerequisite to this is that the DataSet actually knows which column(s) is/are your primary key in that table. Normally this isn't populated so you may have to set this yourself, something like this:

data.Tables["Employees"].PrimaryKey = new DataColumn[] { data.Tables["Employees"].Columns["EmployeeID"] };

In addition, the column displays a combo box as its editor, suggesting values from the primary key table as options. The FilterExpression and SortExpression properties allow the developer to control the list of options available in the editor. These properties are simply handed to .net so SQL-like expressions like "Age > 20" are permitted as the filter.

GridFriendlyGroupNameColumn

This column expects integer data and its companion cell type is GridIntegerCell. It has a GroupNames collection property which contains a list of strings that can be defined at design-time. At runtime whenever the column encounters an integer value it looks up the string in the GroupNames collection at that index and that becomes the formatted value.

The column is invisible at runtime by default. It is intended for situations where you have a grid whose items you want to divide into arbitrary groups. You can set the GroupColumn to this column knowing the column itself is invisible but grouping will still work, using the textual group names you have defined.

GridDecimalColumn, GridDoubleColumn, GridIntegerColumn

These are simply strongly-typed data columns and equivalent cells are also present. They all accept data format strings.

GridImageColumn

This is an advanced column designed to show an image only. There is no corresponding cell type. It is meant for use in databinding scenarious and it can accept either an Image or a type that can be converted one (normally a byte array). It honours the CellHorizontalAlignment and CellVerticalAlignment properties for placing the image.

Next: Data Import and Export