Wijmo 5 - FlexGrid

by Troy Taylor

HTML

<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<div class="container">

  <h1>Select Columns in Plain JS</h1>

  <p>And this one specifies the columns in code:</p>
  <div id="theGrid"></div>

</div>

CSS

.wj-flexgrid {
  height: 200px;
  margin-bottom:24px  
}

JavaScript

// create some random data
  var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
    data = [];
  for (var i = 0; i < countries.length; i++) {
    data.push({
      country: countries[i],
      downloads: Math.round(Math.random() * 20000),
      sales: Math.random() * 10000,
      expenses: Math.random() * 5000
    });
  }

  // initialize a grid in code
  var grid = new wijmo.grid.FlexGrid('#theGrid', {
  	autoGenerateColumns: false,
    itemsSource: data,
    columns: [
      { binding: 'country', header: 'Country' },
      { binding: 'downloads', header: 'Downloads' },
      { binding: 'sales', header: 'Sales', format: 'c' },
      { binding: 'expenses', header: 'Expenses', format: 'c' }
    ]
  });