Search
Grid.rebind Method
See Also
 






Refreshes the Grid after external modifications to the grid model.

Namespace: MindFusion.DataViews
File: Grid.js

 Syntax

JavaScript  Copy Code

function rebind ()

 Example

The following code creates two Grid instances, which share a GridModel with the same GridColumn in it. When the data of the first grid is edited, the rebind method is called on the second grid to update its data: 

JavaScript  Copy Code

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];
var columns2 = [column2, column3];

// create the grid control
var grid = new dv.Grid(document.getElementById("grid"));
grid.width = common.Unit.percentage(50);
grid.theme = "standard";
// set the model
grid.model = new dv.ArrayModel(participants, columns);


// create the grid control
var grid2 = new dv.Grid(document.getElementById("grid2"));
grid2.theme = "pastel";
grid2.width = common.Unit.percentage(50);
// set the model
grid2.model = new dv.ArrayModel(selectedParticipants, columns2);
grid2.render();

grid.rowUpdated.addEventListener(function (sender, args)
  {
    grid2.rebind();
  }
);

 See Also