capture cell values for display elsewhere
capture cell values for display elsewhere
dnagirl
Posts: 36Questions: 2Answers: 0
I have this dataTable setup:
[code]
$(document).ready(function() {
$('#RectifiedCount').dataTable( {
"bJQueryUI": true,
"bProcessing": true,
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"bStateSave": true,
"sDom": '<"H"if>tr<"F"lTp>',
"aoColumns":[
{'sname':'count_id', 'sType':'numeric', 'bVisible':false},
{'sName':'count_type', 'sType':'string','bVisible':true},
{'sName':'count_date', 'sType':'date','bVisible':true},
{'sName':'count_count', 'sType':'numeric','bVisible':true},
{'sName':'count_notes', 'sType':'string','bVisible':true}
],
"oTableTools": {
"sRowSelect": "single",
"sSwfPath": "media/swf/copy_cvs_xls_pdf.swf",
"aButtons": [ {sExtends :'select_none' , 'sButtonText':'Clear Selection'}],
"fnRowSelected": function(node){
var c=$(node).children();
if($(c[0]).text()=='Delivery') return ;
$('select[name="count_type"]').val($(c[0]).text());
$('input[name="count_date"]').val($(c[1]).text());
$('input[name="count_count"]').val($(c[2]).text());
$('textarea[name="count_notes"]').val($(c[3]).text());
}
},
'sScrollX':'100%'
});
});
[/code]
When I select a row, I want to copy the values of the cells of that row into some form fields that are named the same as the 'sName' attributes. I have 2 questions:
- is there a TableTools method for accessing the value of a cell in a selected row? Something like `node['sName_whatever'].value` would be nice.
- how can I get the value of the cells where bVisible=false?
Thanks,
Jen
[code]
$(document).ready(function() {
$('#RectifiedCount').dataTable( {
"bJQueryUI": true,
"bProcessing": true,
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"bStateSave": true,
"sDom": '<"H"if>tr<"F"lTp>',
"aoColumns":[
{'sname':'count_id', 'sType':'numeric', 'bVisible':false},
{'sName':'count_type', 'sType':'string','bVisible':true},
{'sName':'count_date', 'sType':'date','bVisible':true},
{'sName':'count_count', 'sType':'numeric','bVisible':true},
{'sName':'count_notes', 'sType':'string','bVisible':true}
],
"oTableTools": {
"sRowSelect": "single",
"sSwfPath": "media/swf/copy_cvs_xls_pdf.swf",
"aButtons": [ {sExtends :'select_none' , 'sButtonText':'Clear Selection'}],
"fnRowSelected": function(node){
var c=$(node).children();
if($(c[0]).text()=='Delivery') return ;
$('select[name="count_type"]').val($(c[0]).text());
$('input[name="count_date"]').val($(c[1]).text());
$('input[name="count_count"]').val($(c[2]).text());
$('textarea[name="count_notes"]').val($(c[3]).text());
}
},
'sScrollX':'100%'
});
});
[/code]
When I select a row, I want to copy the values of the cells of that row into some form fields that are named the same as the 'sName' attributes. I have 2 questions:
- is there a TableTools method for accessing the value of a cell in a selected row? Something like `node['sName_whatever'].value` would be nice.
- how can I get the value of the cells where bVisible=false?
Thanks,
Jen
This discussion has been closed.
Replies
[code]
{
"sExtends": "text",
"sButtonText": "DoSomething",
"fnClick" : function ( nButton, oConfig, oFlash ) {
var ids;
ids = "";
$('.DTTT_selected td:nth-child(2)').each(function() {
ids+= $(this).text()+",";
});
alert(ids);
}
[/code]
Set TableTools.fnRowSelected to something like this:
[code]
"fnRowSelected": function(node){
aData = rctable.fnGetData(node); //this is how to get the data from a table row
//set some form fields with data from the selected table row
$('input[name="count_id"]').val(aData[0]);//hidden column, hidden form field
$('select#count_type option:contains('+ aData[1]+')').attr('selected',true); //regular column, form select box
$('input#count_date').val(aData[2]); //regular column, form input box
$('input#fish_count').val(aData[3]);
$('textarea#count_notes').val(aData[4]);
}
[/code]