TableTools fnSelect not working...
TableTools fnSelect not working...
cmatta
Posts: 4Questions: 0Answers: 0
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]
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]
This discussion has been closed.
Replies
I'll look at relaxing this constraint on TableTools so jQuery objects can be passed in.
Allan
I'm doing this outside of the dataTables function, is that OK? Should this still work in that case?
Allan
So I'd suggest updating to the latest version.
Allan