1

I'm trying to click on a element of my table in a responsive way, but it doesn't work. It seems that ng-click doesn't work perfectly..

this is my html table:

<table id="listadifferite" datatable="ng"  dt-options="myController.dtOptions"
   class="table table-bordered table-striped" cellspacing="0" width="100%">
   <thead>
      <tr>
         <th>Col1</th>
         <th>Col2</th>
         <th>Col3</th>
         <th>Col4</th>
      </tr>
   </thead>
   <tbody>
      <td data-dt-column="{{differite.idDif}}_0" class="text-center">Prova</td>
      <td data-dt-column="{{differite.idDif}}_1" class="text-center">
         <a ng-click="controllerDif.mostraDettaglio(differite)"><i class="fa fa-search-plus"></i></a>
      </td>
      <td data-dt-column="{{differite.idDif}}_2" class="text-center">Prova</td>
      <td data-dt-column="{{differite.idDif}}_3" class="text-center">Prova</td>
      </tr>
   </tbody>
</table>

and this is dtOptions in myController:

self.dtOptions = DTOptionsBuilder.newOptions()
 .withPaginationType('full_numbers')
 .withOption('responsive', {
  details: {
   type: 'column',
   target: 0
  }
 })

another similar issue here: https://github.com/l-lin/angular-datatables/issues/552

2
  • Is your click inside a repeated scope? You probably need to refer to the parent scope via $parent.controllerDif.mostraDettaglio(differite) Commented Feb 29, 2016 at 14:14
  • it doesn't work however. Commented Feb 29, 2016 at 14:55

1 Answer 1

1

adding this function to the controller fixed it :

 function renderer(api, rowIdx, columns) {
                var data = $.map( columns, function ( col, i ) {
                     return col.hidden ?
                         '<li data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
                              '<span class="dtr-title">'+
                                  col.title+
                            '</span> '+
                            '<span class="dtr-data">'+
                                col.data+
                           '</span>'+
                       '</li>' : 
                       '';
                   }).join('');
                   return data ?
                       $compile(angular.element($('<ul data-dtr-index="'+rowIdx+'"/>').append( data )))($scope) :  
                        false;
               }

and add responsive option

 .withOption('responsive', {
              details: {
                  renderer: renderer
              }
         })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.