Wijmo 5 [Allowing Checkbox for selecting row ]
This fiddle implement selecting row in flex grid using checkbox
HTML
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-2.2.4.min.js"></script>
<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">
<div ng-controller="appCtrl">
<wj-flex-grid items-source="data" item-formatter="itemFormatter" control="flex" style="height: 300px; width: 500px;">
</wj-flex-grid>
<input type="button" ng-click="GetSelectedRows()" value="Get selected rows" />
{{selection}}
</div>
JavaScript
var getData = function (value) {
var countries = 'India,Japan,UK,US,China'.split(','),
data = [];
for (var i = 0; i < value; i++) {
data.push({
id: i + 1,
country: countries[i % countries.length],
sales: Math.random() * 10000,
downloads: Math.random() * 200,
moreSales: Math.random() * 10000,
test: Math.random() * 200,
moreTest: Math.random() * 200,
moreColumns: Math.random() * 200,
active: false
});
}
return data;
};
var app = angular.module('app', ['wj']);
app.controller('appCtrl', function ($scope) {
$scope.data = new wijmo.collections.CollectionView(getData(900));
$scope.itemFormatter = function (panel, r, c, cell) {
if (panel.cellType == wijmo.grid.CellType.Cell) {
var flex = panel.grid;
var row = flex.rows[r];
cell.style.backgroundColor = row.dataItem.active ? 'blue' : '';
}
if (panel.cellType == wijmo.grid.CellType.ColumnHeader) {
var flex = panel.grid;
var col = flex.columns[c];
if (col.dataType == wijmo.DataType.Boolean) {
col.allowSorting = false;
var cnt = 0;
for (var i = 0; i < flex.rows.length; i++) {
if (flex.getCellData(i, c) == true)
cnt++;
}
cell.innerHTML = '<input type="checkbox"> ' + cell.innerHTML;
var cb = cell.firstChild,
checked = cnt > 0;
indeterminate = cnt > 0 && cnt <...