@@ -33,7 +33,8 @@ angular.module('patternfly.table').component('pfTableView', {
3333
3434 ctrl . defaultConfig = {
3535 selectionMatchProp : 'uuid' ,
36- onCheckBoxChange : null
36+ onCheckBoxChange : null ,
37+ showCheckboxes : true
3738 } ;
3839
3940 ctrl . $onInit = function ( ) {
@@ -160,18 +161,22 @@ angular.module('patternfly.table').component('pfTableView', {
160161
161162 function setColumnDefs ( ) {
162163 var i = 0 , actnBtns = 1 ;
163- var item , prop ;
164+ var item , prop , offset ;
165+ ctrl . dtColumnDefs = [ ] ;
164166
165167 // add checkbox col, not sortable
166- ctrl . dtColumnDefs = [ DTColumnDefBuilder . newColumnDef ( i ++ ) . notSortable ( ) ] ;
168+ if ( ctrl . config . showCheckboxes ) {
169+ ctrl . dtColumnDefs . push ( DTColumnDefBuilder . newColumnDef ( i ++ ) . notSortable ( ) ) ;
170+ }
167171
168172 // add column definitions
169173 _ . forEach ( ctrl . columns , function ( column ) {
170174 ctrl . dtColumnDefs . push ( DTColumnDefBuilder . newColumnDef ( i ++ ) ) ;
171175 } ) ;
172176
173- // Determine selectionMatchProp column number (add 1 due to the checkbox column)
174- ctrl . selectionMatchPropColNum = _ . findIndex ( ctrl . columns , [ 'itemField' , ctrl . config . selectionMatchProp ] ) + 1 ;
177+ // Determine selectionMatchProp column number (add offset due to the checkbox column)
178+ offset = ctrl . config . showCheckboxes ? 1 : 0 ;
179+ ctrl . selectionMatchPropColNum = _ . findIndex ( ctrl . columns , [ 'itemField' , ctrl . config . selectionMatchProp ] ) + offset ;
175180
176181 // add actions col.
177182 if ( ctrl . actionButtons && ctrl . actionButtons . length > 0 ) {
@@ -234,43 +239,45 @@ angular.module('patternfly.table').component('pfTableView', {
234239 }
235240
236241 function selectRowsByChecked ( ) {
237- $timeout ( function ( ) {
238- var oTable , rows , checked ;
242+ if ( ctrl . config . showCheckboxes ) {
243+ $timeout ( function ( ) {
244+ var oTable , rows , checked ;
239245
240- oTable = ctrl . dtInstance . DataTable ;
246+ oTable = ctrl . dtInstance . DataTable ;
241247
242- if ( ctrl . debug ) {
243- $log . debug ( " selectRowsByChecked" ) ;
244- }
248+ if ( ctrl . debug ) {
249+ $log . debug ( " selectRowsByChecked" ) ;
250+ }
245251
246- if ( angular . isUndefined ( oTable ) ) {
247- return ;
248- }
252+ if ( angular . isUndefined ( oTable ) ) {
253+ return ;
254+ }
249255
250- if ( ctrl . debug ) {
251- $log . debug ( " ...oTable defined" ) ;
252- }
256+ if ( ctrl . debug ) {
257+ $log . debug ( " ...oTable defined" ) ;
258+ }
253259
254- // deselect all
255- rows = oTable . rows ( ) ;
256- rows . deselect ( ) ;
260+ // deselect all
261+ rows = oTable . rows ( ) ;
262+ rows . deselect ( ) ;
257263
258- // select those with checked checkboxes
259- rows = oTable . rows ( function ( idx , data , node ) {
260- // row td input type=checkbox
261- checked = node . children [ 0 ] . children [ 0 ] . checked ;
262- return checked ;
263- } ) ;
264+ // select those with checked checkboxes
265+ rows = oTable . rows ( function ( idx , data , node ) {
266+ // row td input type=checkbox
267+ checked = node . children [ 0 ] . children [ 0 ] . checked ;
268+ return checked ;
269+ } ) ;
264270
265- if ( ctrl . debug ) {
266- $log . debug ( " ... #checkedRows = " + rows [ 0 ] . length ) ;
267- }
271+ if ( ctrl . debug ) {
272+ $log . debug ( " ... #checkedRows = " + rows [ 0 ] . length ) ;
273+ }
268274
269- if ( rows [ 0 ] . length > 0 ) {
270- rows . select ( ) ;
271- }
272- setSelectAllCheckbox ( ) ;
273- } ) ;
275+ if ( rows [ 0 ] . length > 0 ) {
276+ rows . select ( ) ;
277+ }
278+ setSelectAllCheckbox ( ) ;
279+ } ) ;
280+ }
274281 }
275282
276283 function setSelectAllCheckbox ( ) {
0 commit comments