Wijmo (PureJS) - Width *

FlexGrid using width * to expand the width of the columns to fill out the FlexGrid

by Joel Parks

HTML

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<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>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.chart.min.js"></script>
<div class="container">
  <div id="flexGridNoStar"></div>
</div>

CSS

.wj-flexgrid {
  max-height: 250px;
  margin-bottom: 12px;
}

.header {
  display: inline-block;
  width: 150px;
  text-align: right;
  font-weight: normal;
}

JavaScript

onload = function() {
  // Creates a vector of strings, and a data variable to hold a list of items
  var countries = 'US,Germany,UK,Japan,Italy,Greece,China,Spain,Sweden,Norway,Denmark,Finland'.split(','),
    data = [];
  for (var i = 0; i < 1500; i++) {
    // Creates attributes and assigns values to each of them for each item in the 'data' variable
    data.push({
      id: i,
      country: countries[i % countries.length],
      active: i % 5 != 0,
      downloads: Math.round(Math.random() * 200000),
      sales: Math.random() * 100000,
      expenses: Math.random() * 50000,
      profit: Math.random() * 75000
    });
  }

  // Creates a view for a ListBox and FlexGrid to manipulate the same data
  var gridView = new wijmo.collections.CollectionView(data);

  // Binds the grid to a Wijmo FlexGrid array
  var gridArrayNoStar = new wijmo.grid.FlexGrid('#flexGridNoStar', {
    // Changes the header of the binded value to what is stored in the 'header' attribute
    // You can leave columns out of the table; the 'Active' column is left out
    autoGenerateColumns: false,
    columns: [{
      binding: "id",
      header: "ID"
    }, {
      binding: "country",
      header: "COUNTRY"
    }, {
      binding: "downloads",
      header: "DOWNLOADS"
    }, {
      binding: "sales",
      header: "SALES"
    }, {
      binding: "expenses",
      header: "EXPENSES"
    }, {
    	binding: "profit",
      header: "PROFIT"
    }],
    itemsSource: gridView
  });
  
  // Binds the grid to a Wijmo FlexGrid array
  var gridArrayStar = new wijmo.grid.FlexGrid('#flexGridStar', {
    // Changes the header of the binded value to what is stored in the 'header' attribute
    // You can leave columns out of the table; the 'Active' column is left out
    autoGenerateColumns: false,
    columns: [{
      binding: "id",
      header: "ID",
      width: "*"
    }, {
      binding: "country",
      header: "COUNTRY",
      width: "*"
    }, {
      binding: "downloads",
      header:...