Link to home
Create AccountLog in
Avatar of SiemensSEN
SiemensSEN

asked on

DATATABLE--: How to get row values when a cell is click

Hello,
  I have a datatable where first column is clickable icon,. When the icon is press I would like to get the values in that row. One of the column is hidden:

var oTable= $("#matchTable").dataTable(
           {
               "bJQueryUI": true,     
               "bAutoWidth": false,
               
                "aoColumns": [         
                   { "sWidth": "2%" },         
                   { "sWidth": "30%" },         
                   { "sWidth": "5%"}, 
                   { "sWidth": "20%" ,"bVisible":    false},
                   { "sWidth": "43%"  }
               ],
              // "aaSorting": [[1, 'asc']]
               /* Disable initial sort */
                //"aaSorting": []
                "bSort": false
                
           }

Open in new window



I am able to get the value by doing the following which get me the column value  but the click event is trigger when any cell in the row is pressed. I want it to only execute when the first cell is click

 oTable.$('tr').click( function ()
          {
              var nTds = $('td', this); 
              var aPos = oTable.fnGetPosition( nTds[0]);
                var sData = oTable.fnGetData(this);
                path = sData[3]; // hidden column
                f = sData[1];
                 alert(fle+"/"+path+f);
            });

Open in new window


Also, the first cell in the row may not have a clickable icon. So, in this case the click event should not be fired
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of SiemensSEN
SiemensSEN

ASKER

Thanks Tagit, PierreC
You're welcome.