Wijmo 5 [Allowing Checkbox for selecting row ]
This fiddle implement selecting row in group 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 style="height:500px;" items-source="gdata" item-formatter="itemFormatter" selection-mode="ListBox" control="flex" >
</wj-flex-grid>
<input type="button" ng-click="GetSelectedRows()" value="Get selected rows" />
{{selection}}
</div>
</div>
CSS
.select{
background:blue !important;
}
.deselect{
background:red !important;
}
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,
active: i % 3 == 0
});
}
return data;
};
var app = angular.module('app', ['wj']);
app.controller('appCtrl', function ($scope) {
$scope.gdata = new wijmo.collections.CollectionView(getData(1000));
var groupDesc = new wijmo.collections.PropertyGroupDescription('country');
$scope.gdata.groupDescriptions.push(groupDesc);
$scope.$watch('flex', function() {
var flex = $scope.flex;
if (flex) {
// add a checkbox in group header
flex.formatItem.addHandler(function (s, e) {
if (e.panel == flex.cells && flex.columns[e.col].binding == 'active') {
var row = flex.rows[e.row];
if (row.dataItem.active) {
row.cssClass = 'select';
}
else {
row.cssClass = 'deselect';
}
}
if (e.panel.rows[e.row] instanceof wijmo.grid.GroupRow && e.panel.cellType != wijmo.grid.CellType.RowHeader) {
var chk = document.createElement('input');
chk.type = 'checkbox';
chk.style.marginLeft = '6px';
chk.className = 'custom-check-box';
...