TableTools fnSelect not working...

TableTools fnSelect not working...

cmattacmatta Posts: 4Questions: 0Answers: 0
edited April 2012 in TableTools
Maybe I'm not doing this right, but when I try and do a fnSelect on an item i get "oSettings is null". I've uploaded debug data using the DataTables debugger: http://debug.datatables.net/uzakic

I'm getting an oTT object and the fnSelect function is definitely listed when I inspect it with firebug...

I'm trying to figure out the best way to get/select rows in a table and if this function would work it seems like it might be ideal. I'm just not sure why it isn't working.


Here's my code:

[code]
$('#symmSection').html('');

oTableSymm = $('#symmTable').dataTable({
"bJQueryUI": true,
"aaData": <?= json_encode($this->emc_luns); ?>,
"aoColumns" : [ <?php foreach($this->symmColumns as $title => $item): ?>
<?= '{"sTitle": "'. $title .'",
"mDataProp": "'. $item .'",
"sClass": "'. $item. '"},' ?>
<?php endforeach ?>
],
"aaSorting": [[0, 'asc']],
"sDom": '<"clear">lfrTt',
"bInfo": false,
"bFilter": false,
"bPaginate": false,
"oTableTools": {
"sRowSelect": "multiple",
"aButtons": [{
"sExtends": "text",
"sButtonText": "Add Symms"
},
// {"sExtends": "text",
// "sButtonText": "Select None",
// "fnClick": function(nButton, oConfig, oFlash){
// $('#symmTable tr').removeClass('DTTT_selected');
// }
"select_none"
],

},
"fnInitComplete": function(oSettings){
console.log("Complete");
}

});

aTrs = oTableSymm.fnGetNodes;
oTT = TableTools.fnGetInstance('symmTable');
console.log(oTT);
oTT.fnSelect( $('#symmTable tbody tr')[0] );

var firstSymmValue = $(aTrs[0]).children('td').first().text();
$('input#symm').val(firstSymmValue);

$('input#symm').change(function(){

selectRowFromSymmId($(this).val());
});

// Not able to get fnSelect to work even though I'm properly
// selecting the correct row... fix on monday.
function selectRowFromSymmId(symmId){
console.log(symmId);
console.log(oTT);
var found = $(aTrs).filter(function(){
return $(this).text().indexOf(symmId) === 0;
}).closest('tr');
oTT.fnSelect($(found));
console.log(found);
}

[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Is it line 59 which is giving the error, rather than line 41? In 41 you are passing a node, while in 59 you are passing a jQuery object, but TableTools expects a node. I think that's the issue.

    I'll look at relaxing this constraint on TableTools so jQuery objects can be passed in.

    Allan
  • cmattacmatta Posts: 4Questions: 0Answers: 0
    Allan, thanks for taking a look. The reason I'm doing both kinds is that I wasn't sure, since neither the oTT.fnSelect at line 41, or the one on 59 are actually selecting a row in the table. Appending .get() to the $(found) object still results in the "oSettings is null" error: "return (oSettings.aoData[iRow]!==undefined) ?"

    I'm doing this outside of the dataTables function, is that OK? Should this still work in that case?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Should still work - as long as oTT is still valid. Can you link me to your example please?

    Allan
  • jfobeljfobel Posts: 3Questions: 0Answers: 0
    TableTools.js v2.0.0 does not contain fnSelect(n).
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I don't think fnSelect was in 2.0.0, but it is in the latest version - 2.0.3 :-). The documentation on the web-site for TableTools always refers to the currently stable release, which is why fnSelect is referenced. I am increasingly moving the DataTables extras to fully versioned documentation, but TableTools is one of the ones which is still to be done I'm afraid.

    So I'd suggest updating to the latest version.

    Allan
This discussion has been closed.