Wijmo 5[Flex Grid]
Check box in column header without using itemformatter
HTML
<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.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/interop/angular/wijmo.angular.min.js"></script>
<div ng-app="app" ng-controller="appCtrl">
<wj-flex-grid items-source="data" allow-sorting="false" control="flex" updated-view="updatedView(s,e)" >
<wj-flex-grid-column header="Customer Id" binding="id"></wj-flex-grid-column>
<wj-flex-grid-column header="Country" binding="country"></wj-flex-grid-column>
<wj-flex-grid-column header="Date" binding="date"></wj-flex-grid-column>
<wj-flex-grid-column header="Amount" binding="amount"></wj-flex-grid-column>
<wj-flex-grid-column header="Active" binding="active">
<wj-flex-grid-cell-template cell-type="ColumnHeader">Active <input type="checkbox" ng-model="chkBox" ng-change="isChanged()"/>
</wj-flex-grid-cell-template>
</wj-flex-grid-column>
</wj-flex-grid>
</div>
JavaScript
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = [];
for (var i = 0; i < 10; i++) {
data.push({
id: i,
country: countries[i % countries.length],
date: new Date(2014, i % 12, i % 28),
amount: Math.random() * 10000,
active: i % 4 == 0
});
}
var app = angular.module('app', ['wj']);
app.controller('appCtrl', function ($scope) {
$scope.data = new wijmo.collections.CollectionView(data);
$scope.chkBox = true;
$scope.isChanged = function () {
var flex = $scope.flex;
$scope.chkBox = !$scope.chkBox;
console.log($scope.chkBox);
cell = getGridCell(flex, 0, 4);
// Click on header and update other cell
var cb = cell.lastChild;
cb.checked = $scope.chkBox;
flex.beginUpdate();
for (var i = 0; i < flex.rows.length; i++) {
flex.setCellData(i, 4, cb.checked);
}
flex.endUpdate();
flex.refresh();
};
$scope.updatedView = function (s, e) {
checkBoxChanged(s);
};
function checkBoxChanged(s) {
var flex = s;
var cnt = 0;
for (var i = 0; i < flex.rows.length; i++) {
if (flex.getCellData(i, 4) == true) {
cnt++;
}
}
var cell = getGridCell(flex, 0, 4);
var cb = cell.lastChild;
cb.checked = cnt > 0;
cb.indeterminate = cnt > 0 && cnt < flex.rows.length;
};
//find html for column header
function...