Skip to content

Commit

Permalink
Fixed #971
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Sep 27, 2016
1 parent a3036bc commit 71fc12d
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions components/datatable/datatable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,42 +730,39 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni
}

handleRowClick(event, rowData) {
this.onRowClick.next({originalEvent: event, data: rowData});

if(!this.selectionMode) {
return;
}

let targetNode = event.target.nodeName;
if(targetNode == 'INPUT' || targetNode == 'BUTTON' || targetNode == 'A'
|| (this.domHandler.hasClass(event.target, 'ui-c'))) {
return;
}

if(this.isSelected(rowData)) {
if(this.isSingleSelectionMode()) {
this.selection = null;
this.selectionChange.emit(null);
}
else {
this.selection.splice(this.findIndexInSelection(rowData), 1);
this.selectionChange.emit(this.selection);
}
if(targetNode == 'TD' || (targetNode == 'SPAN' && !this.domHandler.hasClass(event.target, 'ui-c'))) {
this.onRowClick.next({originalEvent: event, data: rowData});

this.onRowUnselect.emit({originalEvent: event, data: rowData, type: 'row'});
}
else {
if(this.isSingleSelectionMode()) {
this.selection = rowData;
this.selectionChange.emit(rowData);
if(!this.selectionMode) {
return;
}
else if(this.isMultipleSelectionMode()) {
this.selection = this.selection||[];
this.selection.push(rowData);
this.selectionChange.emit(this.selection);

if(this.isSelected(rowData)) {
if(this.isSingleSelectionMode()) {
this.selection = null;
this.selectionChange.emit(null);
}
else {
this.selection.splice(this.findIndexInSelection(rowData), 1);
this.selectionChange.emit(this.selection);
}

this.onRowUnselect.emit({originalEvent: event, data: rowData, type: 'row'});
}
else {
if(this.isSingleSelectionMode()) {
this.selection = rowData;
this.selectionChange.emit(rowData);
}
else if(this.isMultipleSelectionMode()) {
this.selection = this.selection||[];
this.selection.push(rowData);
this.selectionChange.emit(this.selection);
}

this.onRowSelect.emit({originalEvent: event, data: rowData, type: 'row'});
this.onRowSelect.emit({originalEvent: event, data: rowData, type: 'row'});
}
}
}

Expand Down

0 comments on commit 71fc12d

Please sign in to comment.