Wijmo 5 [Flex Grid]
Dyanamicaly add column.
by Manish Gupta
HTML
<link rel="stylesheet" href="http://cdn.wijmo.com/5.20162.198/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.20162.198/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.20162.198/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.20162.198/controls/wijmo.grid.min.js"></script>
<button id="add">Add Column</button>
<div id="theGrid"></div>
JavaScript
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
appData = [];
for (var i = 0; i < 10; i++) {
appData.push({
id: i,
country: countries[i % countries.length],
date: new Date(2014, i % 12, i % 28),
amount: Math.random() * 10000,
active: i % 4 == 0
});
}
$(document).ready(function () {
var data = [{ tempVal: 242 }, {tempVal:353}];
var grid = new wijmo.grid.FlexGrid('#theGrid');
grid.itemsSource = new wijmo.collections.CollectionView(appData);
grid.itemsSource.trackChanges = true;
$('#add').click(function () {
$.each(appData, function (i, val) {
val.newCol = data[i%data.length].tempVal
});
var col = new wijmo.grid.Column({ header: 'New Col', binding: 'newCol' });
grid.columns.push(col);
});
});