Show specific column beneath other columns in its own display area (similar to row_details example)?
Show specific column beneath other columns in its own display area (similar to row_details example)?
One of my columns is particularly large (lot of text being displayed) and I want to show it in its own row/table/area beneath the other columns. api/row_details.html is what I am looking to do, but without user interaction needed. I want to display this on table draw and always have it displayed. I am using 1.10 and used api/row_details.html as a reference, but I can't seem to do anything based off the code.
I believe I need to be doing the creation of this new display area in "rowCallback" or is there an easier/better way to go about this?
I really don't have anything to show because nothing I have tried comes close to doing anything... help would be appreciated.
I believe I need to be doing the creation of this new display area in "rowCallback" or is there an easier/better way to go about this?
I really don't have anything to show because nothing I have tried comes close to doing anything... help would be appreciated.
This discussion has been closed.
Replies
In the example it uses 'row.child( format(row.data()) ).show();' to open a row, but that is with a click as well.
my callback is :
[code]
"rowCallback": function( row, data, displayIndex ) {
row.child(format(data));
}
[/code]
then I am creating the new display area with this function...
[code]
function format ( d ) {
// `d` is the original data object for the row
return ''+
''+
'Full name:'+
''+d.name+''+
''+
''+
'Extension number:'+
''+d.extn+''+
''+
''+
'Extra info:'+
'And any further details here (images etc)...'+
''+
'';
}
[/code]
What I am looking to do is have a column displayed in its own row under the 'normal' one.
Ideas? Hints?
This allowed me to create a row and show information on click, but I need it by default.
[code]
$('#sample_1_wrapper').on('click', '.keytest', function () {
var tr = $(this).parents('tr');
var data = dt.fnGetData( tr );
dt.fnOpen( tr, 'test', "info_row" );
});
[/code]
and full code
[code]
dt = $('#sample_1').dataTable({
"dom": "<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-md-12 col-sm-12 text-center'r>><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>><'row'<'col-sm-6'<'#dtLeft'>><'col-sm-6'>>",
"processing": true,
"serverSide": true,
"ajax": "/custom/data-tables/logs-keystrokes.php",
//set columns and rendering
"columns": [
{
"data": "keystroke_id",
"class": "center",
"searchable": false,
"sortable": false,
"render": function ( data ) {
return '';
}
},
{ "data": "computer_username" },
{ "data": "computer_username" },
{ "data": "window_title" },
{
"data": null,
"orderable": false,
"sortable": false,
"defaultContent": 'click me'
},
{ "data": "capture_timestamp" }
],
// set timestamp as initial sorting
"aaSorting": [[5,'desc']],
"drawCallback": function() {
// reset the select/unselect checkbox
$('#sample_1 thead input[type=checkbox]').removeAttr('checked');
// uniform all checkboxes
$('#sample_1 .checkboxes, #sample_1 .group-checkable').uniform();
},
"rowCallback": function( row, data, index ) {
if ( $.inArray((data.DT_RowId).toString(), selected) !== -1 ) {
$(row).addClass('active');
var checkbox = $(row).find('.checkboxes');
$(checkbox).attr("checked", true);
}
}
});
//details formatting
function format ( d ) {
return 'Keystrokes: '+d.keystrokes;
}
$('#sample_1_wrapper').on('click', '.keytest', function () {
var tr = $(this).parents('tr');
var data = dt.fnGetData( tr );
dt.fnOpen( tr, format(data), "info_row" );
});
[/code]
Allan
[code]
$('#sample_1 > tbody > tr').each(function() {
var tr = $(this);
var data = dt.fnGetData( tr );
dt.fnOpen( tr, format(data), "classname");
});
[/code]
Allan