Wijmo 5 - Checkbox in header
by Joel Parks
HTML
<script src="http://cdn.wijmo.com/5.20142.0/controls/wijmo.min.js"></script>
<link rel="stylesheet" href="http://cdn.wijmo.com/5.20142.0/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.20142.0/controls/wijmo.grid.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<script src="http://cdn.wijmo.com/5.20142.0/interop/angular/wijmo.angular.min.js"></script>
<!-- mark this as an Angular application and give it a controller -->
<div ng-app="app" ng-controller="appCtrl">
<h1>Header Checkbox Example</h1>
<wj-flex-grid
items-source="data"
item-formatter="itemFormatter">
<wj-flex-grid-column header="Name" binding="name"></wj-flex-grid-column>
<wj-flex-grid-column header="Age" binding="age"></wj-flex-grid-column>
<wj-flex-grid-column header="Active" binding="active"></wj-flex-grid-column>
</wj-flex-grid>
</div>
JavaScript
// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);
// controller
app.controller('appCtrl', function ($scope) {
// create some data
$scope.data = getData();
// formatter to add checkboxes to boolean columns
$scope.itemFormatter = function (panel, r, c, cell) {
if (panel.cellType == wijmo.grid.CellType.ColumnHeader) {
var flex = panel.grid;
var col = flex.columns[c];
// check that this is a boolean column
if (col.dataType == wijmo.DataType.Boolean) {
// create and initialize checkbox
cell.innerHTML = 'Boolean Column';
}
}
}
});
// function used to get data for the grid
function getData() {
return [
{ name: 'Paul', age: 12, active: true },
{ name: 'Ringo', age: 10, active: true },
{ name: 'George', age: 11, active: false },
{ name: 'John', age: 14, active: false }
];
}