Search
GridColumn Constructor
See Also
 






Initializes a new instance of the GridColumn class.

Namespace: MindFusion.DataViews
File: GridColumn.js

 Syntax

JavaScript  Copy Code

function GridColumn ([name, [dataType, [editable]]])

 Parameters

name
Optional.

String. The name of the field, displayed in the column.

dataType
Optional.

An instance of a DataType-derived class. The type of the column. The classes incluse IntegerType, StringType, ImageType etc.

editable
Optional.

Boolean. A value indicating whether the cells in this column can be edited.

 Example

The following code creates a new Grid instance with 3 GridColumn-s and sets some of the Grid properties:

JavaScript  Copy Code

var dv = MindFusion.DataViews;

var column1 = new dv.GridColumn("index");
column1.dataType = dv.IntegerType;
column1.editable = false;
column1.caption = "#";
columns.push(column1);

var column2 = new dv.GridColumn("name");
column2.dataType = dv.StringType;
column2.caption = "Name";
columns.push(column2);

var column3 = new dv.GridColumn("state");
column3.dataType = dv.LookupType;
column3.caption = "State";
column3.metaData.set("values", states.map(s => [s["Name"]]));
columns.push(column3);

var columns = [column1, column2, column3];

// create the grid control
var grid = new dv.Grid(document.getElementById("grid"));
grid.theme = "business";

// disable inplace editing
grid.allowEdit = false;
// do not show "New row" option in context menu
grid.allowAppend = false;
// do not show "Delete Row" option in context menu
grid.allowDelete = false;
// disable single cell selection
grid.allowCellSelect = false;
// set the model
grid.model = new dv.ArrayModel(participants, columns);
//the first column is sorted
grit.sortedColumn = 0;

 See Also