Search
ArrayModel Constructor
See Also
 






Initializes a new instance of the ArrayModel class.

Namespace: MindFusion.DataViews
File: ArrayModel.js

 Syntax

JavaScript  Copy Code

function ArrayModel (values, columns, [keyField])

 Parameters

values

Array. The array to use as a backing store.

columns

Array. The list of display columns.

keyField
Optional.

String. The name of the unique key field.

 Example

The following code creates a new Grid using an HTML <div> element with an id "grid". It creates a new ArrayModel with values from a JavaScript array called "participants". A list with columns is created and provided as the second parameter in the constructor. The key field is "index":

JavaScript  Copy Code

var dv = MindFusion.DataViews;

// create the grid columns
var columns = [];

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);

// create the grid control
var grid = new dv.Grid(document.getElementById("grid"));
grid.theme = "blue";
// set the model
grid.model = new dv.ArrayModel(participants, columns, "index");

 See Also