I am showing data usingui-grid.
The ui-grid
has three columns. The first column is contains checkbox
for each row.
Data populating correctly, row selection works fine except the following issue.
Problem:
When row clicked, the checkbox should also be selected. How i can achieve this? Any Idea?
html
<div class="row">
<div class="col-lg-12">
<div class="datalist-uigrid testGrid">
<div class="grid testGrid" ui-grid="gridOptions" ui-grid-selection ui-grid-auto-resize></div>
</div>
</div>
</div>
Controller
This is how i am defining my field.
{
field: 'selected',
displayName: '',
type: 'boolean',
cellTemplate: uiGridTemplates.cellTemplates.buildCheckboxEditCell('row.entity.IsOneOff', 'row.entity.selected', ' ng-change="grid.appScope.onSelectChange()"'),
enableFiltering: false,
enableSorting: false,
width: '3%'
},
gridOptions
$scope.gridOptions = {
enableRowSelection: true,
enableRowHeaderSelection: false,
enableCellEdit: false,
enableCellEditOnFocus: false,
enableSorting: true,
enableFiltering: true,
multiSelect: false,
enableColumnMenus: false,
enableGridMenu: false,
rowHeight: 60,
modifierKeysToMultiSelect: false,
noUnselect: true,
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
}
};
This is how i am intercepting row click event
$scope.gridOptions.onRegisterApi = function (gridApi) {
$scope.gridApi = gridApi;
gridApi.selection.on.rowSelectionChanged($scope, function (row) {
$scope.onSelectRowChange(row.entity);
var msg = 'row selected ' + row.isSelected;
});
};