Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
base repository: angular-ui/ui-grid
Choose a Base Repository
angular-ui/ui-grid
Aardvark71/ng-grid
AdelinGhanaem/ng-grid
AlasdairSwan/ng-grid
AntonFend/ng-grid
CNXTEoEorg/ui-grid
Dashue/ng-grid
Donderda/ng-grid
EricEngineered/ng-grid
EugeneBorshch/ng-grid
EugeneTruly/ng-grid
GenesysPureConnect/ng-grid
Jammasternam/ng-grid
JavaBasketball/ui-grid
Jenk-Rendar/ng-grid
JonahKE/ui-grid
KNaved/ui-grid
Klarence/ng-grid
Martin17/ng-grid
Mistobaan/ng-grid
Moreface/ng-grid
Pasha-Pramati/ng-grid
Premier/ng-grid
Reskov/ng-grid
SummerDejavu/ng-grid
UrvilKaswala/ng-grid
Wiinis/ng-grid
YonatanKra/ui-grid
a5sk4s/ng-grid
aaks2010/ng-grid
akhileshappala/ui-grid
alecswan/ng-grid
alexspurling/ng-grid
alpinegizmo/ng-grid
anuradha18/ng-grid
archsh/ng-grid
ata-n/ng-grid
avgalon/ng-grid
avikaco/ng-grid
ballmw/ng-grid
bbradbury/ng-grid
benjaminkitt/ng-grid
benmj/ng-grid
blackneus/ng-grid
bmleite/ng-grid
boland/ng-grid
bpoussin/ng-grid
bradlund/ng-grid
bundance/ng-grid
caphun/ng-grid
ccreed2/ui-grid
cdesogeti/ng-grid
ceolter/ui-grid
chanu587/ng-grid
chinnurtb/ng-grid
chiragchamoli/ng-grid
choroshin/ng-grid
christoffee/ng-grid
clkao/ng-grid
cxl55/ng-grid
daclubb/ng-grid
darkhorse-dev/ui-grid
darknos/ng-grid
dcolens/ng-grid
dean-me/ng-grid
demon-lord/ng-grid
devony/ng-grid
doctorsender/ng-grid
ebraminio/ng-grid
ezecafre89/ng-grid
felixhummel/ng-grid
firmusoft/ng-grid
francescoagati/ng-grid
frogomatic/ng-grid
garaboncias/ng-grid
getuliojr/ng-grid
giosakti/ng-grid
goldhand/ng-grid
goodluck2016/ui-grid
hawtio/ng-grid
hey24sheep/ui-grid
hoshidaniel/ng-grid
hotings/ng-grid
hucarrot/ng-grid
imloama/ng-grid
ineedfat/ng-grid
is-fredrik/ng-grid
ismakv/ui-grid
itxd/ui-grid
jeado/ng-grid
jeanpuga/ui-grid
jeffbcross/ng-grid
jeffslofish/ng-grid
jessegavin/ng-grid
jfzman/ng-grid
jharohit/ng-grid
jiacomino/ng-grid
jimhotchkin-wf/ng-grid
jimmytheneutrino/ng-grid
jmaynier/ng-grid
johlrich/ng-grid
johnobe/ng-grid
johnparn/ng-grid
jon23cooper/ng-grid
jozzhart/ng-grid
jspeshu/ng-grid
jstrachan/ng-grid
juliofreitas/ui-grid
jurby/ng-grid
karnyj/ng-grid
keathley/ng-grid
keithharvey/ng-grid
kmussel/ng-grid
koen-serry/ng-grid
konrad-garus/ng-grid
krahman/ng-grid
ksmoore/ng-grid
kugel-soft/ui-grid
lebedevsergey/ui-grid-fix-issue-with-pinned-columns-in-v2
leninloganathan/ui-grid
liergouzi/ui-grid
loiphamvn/ng-grid
longFeiLi/ui-grid
marciosartini/ng-grid
marklagendijk/ng-grid
martijnve/ng-grid
mathiasdose/ng-grid
mathieurivest/ng-grid
matpaprocki/ng-grid
mattlaver/ng-grid
maxcan/ng-grid
mchapman/ng-grid
mediaprojects/ng-grid
mgibson/ng-grid
mheye/ng-grid
mmatczak/ui-grid
mschroering/ng-grid
musically-ut/ng-grid
mxreppy/ng-grid
niilante/ui-grid
nishant8BITS/ng-grid
noming/ng-grid
nuclearghost/ng-grid
orneryd/ng-grid
owenXin/ng-grid
pdegenhardt/ng-grid
pdemanget/ng-grid
ppollono/ng-grid
prabhat2233/ui-grid
presidento/ng-grid
r7lemieux/ng-grid
richiepreece/ng-grid
ronbuchanan/ng-grid
sagarwasule/ng-grid
sapronlee/ng-grid
satyanand/ng-grid
sax1johno/ui-grid
seankenny/ng-grid
simonengelhardt/ng-grid
simplyjames/ng-grid
skusunam/ng-grid
snapappointments/ui-grid
sofibraun/ng-grid
solvebio/ng-grid
songguang-2010/ng-grid
sonicparke/ng-grid
sourcec0de/ng-grid
sravanthipoujula/ng-grid
sskyy/ng-grid
stan-z/ng-grid
strider820/ng-grid
sunfirefox/ng-grid
surfer26th/ng-grid
suryasingh/ng-grid
swalters/ng-grid
tcrimi/ng-grid
tetralon/ng-grid
thedarkjester/ng-grid
tjosbon/ng-grid
tkhemani/ng-grid
tradingscreen/ng-grid
tuckerjt07/ui-grid
turn/ng-grid
uapui-dev/ng-grid
vargose/ng-grid
vladovidiu/ng-grid
wdmny/ng-grid
wp-ng/ui-grid
xordad/ng-grid
xtidt/ui-grid
xtreme-christophe/ng-grid
yangsong158/ui-grid
yanl/ng-grid
yarl/ng-grid
yesnault/ng-grid
yunmanger1/ng-grid
zelingo/ui-grid
zhangdiwaa/ng-grid
zhanghaihua/ng-grid
ztp130213/ng-grid
Nothing to show
base: e1a857074133
head repository: angular-ui/ui-grid
Choose a Head Repository
angular-ui/ui-grid
Aardvark71/ng-grid
AdelinGhanaem/ng-grid
AlasdairSwan/ng-grid
AntonFend/ng-grid
CNXTEoEorg/ui-grid
Dashue/ng-grid
Donderda/ng-grid
EricEngineered/ng-grid
EugeneBorshch/ng-grid
EugeneTruly/ng-grid
GenesysPureConnect/ng-grid
Jammasternam/ng-grid
JavaBasketball/ui-grid
Jenk-Rendar/ng-grid
JonahKE/ui-grid
KNaved/ui-grid
Klarence/ng-grid
Martin17/ng-grid
Mistobaan/ng-grid
Moreface/ng-grid
Pasha-Pramati/ng-grid
Premier/ng-grid
Reskov/ng-grid
SummerDejavu/ng-grid
UrvilKaswala/ng-grid
Wiinis/ng-grid
YonatanKra/ui-grid
a5sk4s/ng-grid
aaks2010/ng-grid
akhileshappala/ui-grid
alecswan/ng-grid
alexspurling/ng-grid
alpinegizmo/ng-grid
anuradha18/ng-grid
archsh/ng-grid
ata-n/ng-grid
avgalon/ng-grid
avikaco/ng-grid
ballmw/ng-grid
bbradbury/ng-grid
benjaminkitt/ng-grid
benmj/ng-grid
blackneus/ng-grid
bmleite/ng-grid
boland/ng-grid
bpoussin/ng-grid
bradlund/ng-grid
bundance/ng-grid
caphun/ng-grid
ccreed2/ui-grid
cdesogeti/ng-grid
ceolter/ui-grid
chanu587/ng-grid
chinnurtb/ng-grid
chiragchamoli/ng-grid
choroshin/ng-grid
christoffee/ng-grid
clkao/ng-grid
cxl55/ng-grid
daclubb/ng-grid
darkhorse-dev/ui-grid
darknos/ng-grid
dcolens/ng-grid
dean-me/ng-grid
demon-lord/ng-grid
devony/ng-grid
doctorsender/ng-grid
ebraminio/ng-grid
ezecafre89/ng-grid
felixhummel/ng-grid
firmusoft/ng-grid
francescoagati/ng-grid
frogomatic/ng-grid
garaboncias/ng-grid
getuliojr/ng-grid
giosakti/ng-grid
goldhand/ng-grid
goodluck2016/ui-grid
hawtio/ng-grid
hey24sheep/ui-grid
hoshidaniel/ng-grid
hotings/ng-grid
hucarrot/ng-grid
imloama/ng-grid
ineedfat/ng-grid
is-fredrik/ng-grid
ismakv/ui-grid
itxd/ui-grid
jeado/ng-grid
jeanpuga/ui-grid
jeffbcross/ng-grid
jeffslofish/ng-grid
jessegavin/ng-grid
jfzman/ng-grid
jharohit/ng-grid
jiacomino/ng-grid
jimhotchkin-wf/ng-grid
jimmytheneutrino/ng-grid
jmaynier/ng-grid
johlrich/ng-grid
johnobe/ng-grid
johnparn/ng-grid
jon23cooper/ng-grid
jozzhart/ng-grid
jspeshu/ng-grid
jstrachan/ng-grid
juliofreitas/ui-grid
jurby/ng-grid
karnyj/ng-grid
keathley/ng-grid
keithharvey/ng-grid
kmussel/ng-grid
koen-serry/ng-grid
konrad-garus/ng-grid
krahman/ng-grid
ksmoore/ng-grid
kugel-soft/ui-grid
lebedevsergey/ui-grid-fix-issue-with-pinned-columns-in-v2
leninloganathan/ui-grid
liergouzi/ui-grid
loiphamvn/ng-grid
longFeiLi/ui-grid
marciosartini/ng-grid
marklagendijk/ng-grid
martijnve/ng-grid
mathiasdose/ng-grid
mathieurivest/ng-grid
matpaprocki/ng-grid
mattlaver/ng-grid
maxcan/ng-grid
mchapman/ng-grid
mediaprojects/ng-grid
mgibson/ng-grid
mheye/ng-grid
mmatczak/ui-grid
mschroering/ng-grid
musically-ut/ng-grid
mxreppy/ng-grid
niilante/ui-grid
nishant8BITS/ng-grid
noming/ng-grid
nuclearghost/ng-grid
orneryd/ng-grid
owenXin/ng-grid
pdegenhardt/ng-grid
pdemanget/ng-grid
ppollono/ng-grid
prabhat2233/ui-grid
presidento/ng-grid
r7lemieux/ng-grid
richiepreece/ng-grid
ronbuchanan/ng-grid
sagarwasule/ng-grid
sapronlee/ng-grid
satyanand/ng-grid
sax1johno/ui-grid
seankenny/ng-grid
simonengelhardt/ng-grid
simplyjames/ng-grid
skusunam/ng-grid
snapappointments/ui-grid
sofibraun/ng-grid
solvebio/ng-grid
songguang-2010/ng-grid
sonicparke/ng-grid
sourcec0de/ng-grid
sravanthipoujula/ng-grid
sskyy/ng-grid
stan-z/ng-grid
strider820/ng-grid
sunfirefox/ng-grid
surfer26th/ng-grid
suryasingh/ng-grid
swalters/ng-grid
tcrimi/ng-grid
tetralon/ng-grid
thedarkjester/ng-grid
tjosbon/ng-grid
tkhemani/ng-grid
tradingscreen/ng-grid
tuckerjt07/ui-grid
turn/ng-grid
uapui-dev/ng-grid
vargose/ng-grid
vladovidiu/ng-grid
wdmny/ng-grid
wp-ng/ui-grid
xordad/ng-grid
xtidt/ui-grid
xtreme-christophe/ng-grid
yangsong158/ui-grid
yanl/ng-grid
yarl/ng-grid
yesnault/ng-grid
yunmanger1/ng-grid
zelingo/ui-grid
zhangdiwaa/ng-grid
zhanghaihua/ng-grid
ztp130213/ng-grid
Nothing to show
compare: e5f8dfa7d654
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 2 contributors
Commits on Dec 21, 2014
Fix #2394 (selection): make enableRowSelection dynamic
@@ -101,7 +101,7 @@ Two examples are provided, the first with rowHeaderSelection and multi-select, t
};
}]);

app.controller('SecondCtrl', ['$scope', '$http', '$interval', function ($scope, $http, $interval) {
app.controller('SecondCtrl', ['$scope', '$http', '$interval', 'uiGridConstants', function ($scope, $http, $interval, uiGridConstants) {
$scope.gridOptions = { enableRowSelection: true, enableRowHeaderSelection: false };

$scope.gridOptions.columnDefs = [
@@ -118,6 +118,12 @@ Two examples are provided, the first with rowHeaderSelection and multi-select, t
$scope.gridApi = gridApi;
};

$scope.toggleRowSelection = function() {
$scope.gridApi.selection.clearSelectedRows();
$scope.gridOptions.enableRowSelection = !$scope.gridOptions.enableRowSelection;
$scope.gridApi.core.notifyDataChange( $scope.gridApi.grid, uiGridConstants.dataChange.OPTIONS);
};

$http.get('/data/500_complex.json')
.success(function(data) {
$scope.gridOptions.data = data;
@@ -143,7 +149,9 @@ Two examples are provided, the first with rowHeaderSelection and multi-select, t
<div ui-grid="gridOptions" ui-grid-selection class="grid"></div>
</div>
<div ng-controller="SecondCtrl">
Single selection grid without rowHeader:
Single selection grid without rowHeader, and allowing rowSelection to be toggled on and off dynamically:
<br/>
<button type="button" class="btn btn-success" ng-click="toggleRowSelection()">Toggle rowSelection</button> <strong>rowSelection:</strong> <span ng-bind="gridApi.grid.options.enableRowSelection"></span>
<div ui-grid="gridOptions" ui-grid-selection class="grid"></div>
</div>
</file>
@@ -38,7 +38,7 @@

/**
* @ngdoc object
* @name enableRowSelection
* @name enablePinning
* @propertyOf ui.grid.pinning.api:GridOptions
* @description Enable pinning for the entire grid.
* <br/>Defaults to true
@@ -649,45 +649,74 @@
scope: false,
link: function ($scope, $elm, $attrs) {

if ($scope.grid.options.enableRowSelection && !$scope.grid.options.enableRowHeaderSelection) {
$elm.addClass('ui-grid-disable-selection');
registerRowSelectionEvents();
}

function registerRowSelectionEvents() {
var touchStartTime = 0;
var touchTimeout = 300;
var selectCells = function(evt){
if (evt.shiftKey) {
uiGridSelectionService.shiftSelect($scope.grid, $scope.row, $scope.grid.options.multiSelect);
}
else if (evt.ctrlKey || evt.metaKey) {
uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, $scope.grid.options.multiSelect, $scope.grid.options.noUnselect);
}
else {
uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect), $scope.grid.options.noUnselect);
}
$scope.$apply();
};

$elm.on('touchstart', function(event) {
touchStartTime = (new Date()).getTime();
});

$elm.on('touchend', function (evt) {
var touchEndTime = (new Date()).getTime();
var touchTime = touchEndTime - touchStartTime;
var touchStartTime = 0;
var touchTimeout = 300;
var selectCells = function(evt){
if (evt.shiftKey) {
uiGridSelectionService.shiftSelect($scope.grid, $scope.row, $scope.grid.options.multiSelect);
}
else if (evt.ctrlKey || evt.metaKey) {
uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, $scope.grid.options.multiSelect, $scope.grid.options.noUnselect);
}
else {
uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect), $scope.grid.options.noUnselect);
}
$scope.$apply();
};

if (touchTime < touchTimeout ) {
// short touch
selectCells(evt);
}
});
var touchStart = function(evt){
touchStartTime = (new Date()).getTime();
};

var touchEnd = function(evt) {
var touchEndTime = (new Date()).getTime();
var touchTime = touchEndTime - touchStartTime;

$elm.on('click', function (evt) {
if (touchTime < touchTimeout ) {
// short touch
selectCells(evt);
});
}
};

function registerRowSelectionEvents() {
if ($scope.grid.options.enableRowSelection && !$scope.grid.options.enableRowHeaderSelection) {
$elm.addClass('ui-grid-disable-selection');
$elm.on('touchstart', touchStart);
$elm.on('touchend', touchEnd);
$elm.on('click', selectCells);

$scope.registered = true;
}
}

function deregisterRowSelectionEvents() {
if ($scope.registered){
$elm.removeClass('ui-grid-disable-selection');

$elm.off('touchstart', touchStart);
$elm.off('touchend', touchEnd);
$elm.off('click', selectCells);

$scope.registered = false;
}
}

registerRowSelectionEvents();
// register a dataChange callback so that we can change the selection configuration dynamically
// if the user changes the options
var callbackId = $scope.grid.registerDataChangeCallback( function() {
if ( $scope.grid.options.enableRowSelection && !$scope.grid.options.enableRowHeaderSelection &&
!$scope.registered ){
registerRowSelectionEvents();
} else if ( ( !$scope.grid.options.enableRowSelection || $scope.grid.options.enableRowHeaderSelection ) &&
$scope.registered ){
deregisterRowSelectionEvents();
}
}, [uiGridConstants.dataChange.OPTIONS] );

$scope.$on( '$destroy', function() {
$scope.grid.deregisterDataChangCallback( callbackId );
});
}
};
}]);
@@ -89,7 +89,8 @@
ALL: 'all',
EDIT: 'edit',
ROW: 'row',
COLUMN: 'column'
COLUMN: 'column',
OPTIONS: 'options'
},
scrollbars: {
NEVER: 0,
@@ -104,7 +104,6 @@
}
}


$scope.$on('$destroy', function() {
dataWatchCollectionDereg();
columnDefWatchCollectionDereg();
@@ -291,16 +291,18 @@ angular.module('ui.grid')
* - when the api is called to inform us of a change, the declared type of that change is used
* - when a cell edit completes, the EDIT callbacks are triggered
* - when the columnDef watch fires, the COLUMN callbacks are triggered
* - when the options watch fires, the OPTIONS callbacks are triggered
*
* For a given event:
* - ALL calls ROW, EDIT, COLUMN and ALL callbacks
* - ALL calls ROW, EDIT, COLUMN, OPTIONS and ALL callbacks
* - ROW calls ROW and ALL callbacks
* - EDIT calls EDIT and ALL callbacks
* - COLUMN calls COLUMN and ALL callbacks
* - OPTIONS calls OPTIONS and ALL callbacks
*
* @param {function(grid)} callback function to be called
* @param {array} types the types of data change you want to be informed of. Values from
* the uiGridConstants.dataChange values ( ALL, EDIT, ROW, COLUMN ). Optional and defaults to
* the uiGridConstants.dataChange values ( ALL, EDIT, ROW, COLUMN, OPTIONS ). Optional and defaults to
* ALL
* @returns {string} uid of the callback, can be used to deregister it again
*/
@@ -332,10 +334,10 @@ angular.module('ui.grid')
* @name callDataChangeCallbacks
* @methodOf ui.grid.class:Grid
* @description Calls the callbacks based on the type of data change that
* has occurred. Always calls the ALL callbacks, calls the ROW, EDIT, and COLUMN callbacks if the
* has occurred. Always calls the ALL callbacks, calls the ROW, EDIT, COLUMN and OPTIONS callbacks if the
* event type is matching, or if the type is ALL.
* @param {number} type the type of event that occurred - one of the
* uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN)
* uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN, OPTIONS)
*/
Grid.prototype.callDataChangeCallbacks = function callDataChangeCallbacks(type, options) {
angular.forEach( this.dataChangeCallbacks, function( callback, uid ){
@@ -363,7 +365,8 @@ angular.module('ui.grid')
if ( type === constants.ALL ||
type === constants.COLUMN ||
type === constants.EDIT ||
type === constants.ROW ){
type === constants.ROW ||
type === constants.OPTIONS ){
grid.callDataChangeCallbacks( type );
} else {
gridUtil.logError("Notified of a data change, but the type was not recognised, so no action taken, type was: " + type);

No commit comments for this range

You can’t perform that action at this time.