TableTools - Always null?

TableTools - Always null?

1DMF1DMF Posts: 16Questions: 5Answers: 0
edited September 2014 in Free community support

Hi,

I have been unsuccessful in getting TableTools to work.

i have this datatable...

    Updates = $('#compliance_updates_list').DataTable({   
     
        "sDom": 'R<"H"fr>t<"F"ip>', 
        "oTableTools": {
            "sRowSelect": "single"
        },   
                
        "bJQueryUI": true,

        "sPaginationType": "full_numbers",

        "iDisplayLength": 5,

        "aoColumnDefs": [{ "sType": "uk_date", "aTargets": [1] }],

        "order": [[ 1, "desc" ]]

    });

But no matter how I try to get a TableTool object it is always null?

TableTools.fnGetInstance( '#compliance_updates_list' );
TableTools.fnGetInstance( 'compliance_updates_list' );
TableTools.fnGetInstance( Updates );
TableTools.fnGetInstance( $('#compliance_updates_list') );

If I console.log(TableTools) I get an object, so the plug-in script has loaded?

Why can't I get a TableTools object for my DataTable?

I solved my current issue by doing it this way

$('#compliance_updates_list tr.selected td:first').html()

So do i need to even bother loading this plug-in when the above does the same job as fnGetData[0] ?

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Have you looked at the example in the docs?
    http://datatables.net/extensions/tabletools/

    You need to include TableTools in your "dom" initialisation - capital T - and you need to define your path to swf file.

    I don't understand your last remark. Are you saying that this
    $('#compliance_updates_list tr.selected td:first').attr('data-desc')

    is the same as using TableTools?

  • 1DMF1DMF Posts: 16Questions: 5Answers: 0
    edited September 2014

    No, I actually edited my post

    $('#compliance_updates_list tr.selected td:first').html()
    

    As i feel that's more accurate to being on a par...

    But what I meant was if I can get the table cell data without using the plug-in, perhaps it isn't necessary. Though that breaks the minute the columns are rearranged, so I guess I need to persevere as I assume the plugin will fix this column switching issue?

    I was going to use the data attribute or ID's and JQuery instead, but if this tool resolves all this, then I'd like to get it working.

    What I want is to get a particular columns value from a selected row, I can't see any method in the standard DataTable API for doing this?

  • 1DMF1DMF Posts: 16Questions: 5Answers: 0

    OK, just been playing with row().data() , but that has the same problem, when the columns are drag/dropped in a different order.

    I must be missing some column binding somewhere?

  • 1DMF1DMF Posts: 16Questions: 5Answers: 0
    edited September 2014

    Well I just seem to be going round in circles unable to do this simplest of things, get the cell value of a selected row!

    Updates.row().column('Description:name').data().toString()
    

    all that gives me is [Object Object]

    I can't get the selected row all I ever get is every row? Even when I pass it the node of the selected row

    Updates.row($('#compliance_updates_list tr.selected').get(0)).column('Description:name').data()[0].toString()
    

    I still just get an array of every row?

This discussion has been closed.