get cell value in dataTable

I am using datatable.net plugin.  i need to get the value of data that is in the dataset but not displayed in the grid (if that matters).  I have tried several things but can't get it to work.


        var tableTools = new $.fn.dataTable.TableTools( table, {
                  sRowSelect: "os",
                  aButtons: [
                  {
                      sExtends: 'select_single',
                      sButtonClass: 'marginLeft',
                      sButtonText: 'View History',
                      editor: editor,
                      fnClick: function () {
                        //window.location.href = 'grid_staffHistory.php';
                        //alert( 'Row index: '+table.row( '.selected' ).index() );
                        alert( 'primary key: '+table.row( '.selected' ).cell('usertable.uuk').data() );
                        //alert( 'Row index: '+ editor.get('usertable.uuk') );
                      }
                  },                  
                  {
                      sExtends: 'select_single',
                      sButtonClass: 'marginLeft',
                      sButtonText: 'Add New Staff',
                      fnClick: function () {
                        window.location.href = 'addUsers.php';
                      }
                  }                      
                  ]
              } );
        $( tableTools.fnContainer() ).insertBefore( '#table_filter' );          
    });
LVL 7
UniqueDataAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
If you need to get data you are not placing in the table, you can put it in an attribute like
 <td data-extra="abc123">a Tiger Nixon</td>

Open in new window

I created a datatable example from the zero config for you http://jsbin.com/pacaguyuzi/1/edit?html,js,output

Note the first column on the first row has the data- attribute.
<tr>
                <td data-extra="abc123">a Tiger Nixon</td>
                <td>System Architect</td>
                <td>Edinburgh</td>
                <td>61</td>
                <td>2011/04/25</td>
                <td>$320,800</td>
            </tr>

Open in new window


I used the code below to get it
$(document).ready(function() {
    $('#example').DataTable();
     $('td').click(function(){
       var t=$(this).text();
       var e =$(this).attr('data-extra');
       alert(t);
       alert(e);
     }); 
      
} );

Open in new window

Give the sample a try and let me know if that is what you are trying to do
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
fyi, the link above was fixed and you will need to click on the first column of the first row for "a tiger nixon"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
UniqueDataAuthor Commented:
your answer let me down the right path.  When I defined the editor I needed to include that field, but as hidden.  Then, one of the lines I had commented out would work.

        editor = new $.fn.dataTable.Editor( {
            serverSide: true,
            ajax: "lib/getdata.php",
            table: "#table",
            idSrc: "usertable.uuk",
            fields: [
              {
                name: "usertable.uuk", 
                visible: "false"
              },
            //rest of visible fields here

Open in new window


then...
        var tableTools = new $.fn.dataTable.TableTools( table, {
                  sRowSelect: "os",
                  aButtons: [
                  {
                      sExtends: 'select_single',
                      sButtonClass: 'marginLeft',
                      sButtonText: 'View History',
                      editor: editor,
                      fnClick: function () {
                        //window.location.href = 'grid_staffHistory.php';
                        alert( 'Row identifier: '+ editor.get('usertable.uuk') );
                      }
                  },  

Open in new window

0
UniqueDataAuthor Commented:
Thank you for getting me on the right path :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.