fnOpen - how to access "the source aaData" instead of fnGetData(nTr) which delivers "rendered" data?
fnOpen - how to access "the source aaData" instead of fnGetData(nTr) which delivers "rendered" data?
Hello,
based on the "DataTables hidden row details example" at http://datatables.net/release-datatables/examples/api/row_details.html
I have added a hidden table with all cards listed to the DataTables with game scores at my webpages like this one:
http://preferans.de/user.php?id=OK29066873223 and the users like it, but I have one problem:
[code]
aoColumns: [
.......
/* 10: name */ { fnRender: renderName0 },
/* 11: avatar */ { bVisible: false },
/* 12: city */ { fnRender: renderCity0 },
........
$('#cards_table tbody td img.details').live('click', function(){
var nTr = $(this).parents('tr')[0];
if (cardsTable.fnIsOpen(nTr)) {
this.src = '/images/details_open.png';
cardsTable.fnClose(nTr);
} else {
this.src = '/images/details_close.png';
cardsTable.fnOpen(nTr, renderGame(cardsTable, nTr), 'details');
}
});
[/code]
[code]
function renderGame(cardsTable, nTr) {
var aData = cardsTable.fnGetData(nTr);
var cards = aData[1];
var trix = cards['TRIX'];
var winner = cards['WINNER'];
var id = [ aData[9], aData[19], aData[29] ];
var pos = [ '(' + (1 + aData[5]) + ') ',
'(' + (1 + aData[15]) + ') ',
'(' + (1 + aData[25]) + ') ' ];
var player = [ '
' + pos[0] + aData[10],
pos[1] + aData[20] + '
',
pos[2] + aData[30] + '
' ];
var run = '';
if ($.isArray(trix) && $.isArray(winner)) {
for (var i = 0; i < trix.length && i < winner.length; i++) {
run += (i + 1) + ': ' + renderCards(trix[i], '') +
' » ' + (1 + winner[i]) + '
';
}
}
var str = '' + ........ etc.
return str;
}
[/code]
In my renderGame function drawing the "hidden row" I need to acces the player "name" which is aoColumns[10].
But it is already changed (color changed and link added) by the renderName0 (please see above).
Is there please a way to access the "pure data" (from aaData) instead of the "rendered tr" from fnOpen method?
I.e. I need something else as replacement for the [code]var aData = cardsTable.fnGetData(nTr);[/code] above.
The debug code is at http://debug.datatables.net/onurun
Thank you for any hints
Alex
based on the "DataTables hidden row details example" at http://datatables.net/release-datatables/examples/api/row_details.html
I have added a hidden table with all cards listed to the DataTables with game scores at my webpages like this one:
http://preferans.de/user.php?id=OK29066873223 and the users like it, but I have one problem:
[code]
aoColumns: [
.......
/* 10: name */ { fnRender: renderName0 },
/* 11: avatar */ { bVisible: false },
/* 12: city */ { fnRender: renderCity0 },
........
$('#cards_table tbody td img.details').live('click', function(){
var nTr = $(this).parents('tr')[0];
if (cardsTable.fnIsOpen(nTr)) {
this.src = '/images/details_open.png';
cardsTable.fnClose(nTr);
} else {
this.src = '/images/details_close.png';
cardsTable.fnOpen(nTr, renderGame(cardsTable, nTr), 'details');
}
});
[/code]
[code]
function renderGame(cardsTable, nTr) {
var aData = cardsTable.fnGetData(nTr);
var cards = aData[1];
var trix = cards['TRIX'];
var winner = cards['WINNER'];
var id = [ aData[9], aData[19], aData[29] ];
var pos = [ '(' + (1 + aData[5]) + ') ',
'(' + (1 + aData[15]) + ') ',
'(' + (1 + aData[25]) + ') ' ];
var player = [ '
' + pos[0] + aData[10],
pos[1] + aData[20] + '
',
pos[2] + aData[30] + '
' ];
var run = '';
if ($.isArray(trix) && $.isArray(winner)) {
for (var i = 0; i < trix.length && i < winner.length; i++) {
run += (i + 1) + ': ' + renderCards(trix[i], '') +
' » ' + (1 + winner[i]) + '
';
}
}
var str = '' + ........ etc.
return str;
}
[/code]
In my renderGame function drawing the "hidden row" I need to acces the player "name" which is aoColumns[10].
But it is already changed (color changed and link added) by the renderName0 (please see above).
Is there please a way to access the "pure data" (from aaData) instead of the "rendered tr" from fnOpen method?
I.e. I need something else as replacement for the [code]var aData = cardsTable.fnGetData(nTr);[/code] above.
The debug code is at http://debug.datatables.net/onurun
Thank you for any hints
Alex
This discussion has been closed.
Replies
Setting that parameter might be good enough for you, but you might also want to consider using mDataProp as a function, as described in this blog post: http://datatables.net/blog/Orthogonal_data . This method allows different data to be used for each aspect of how the data is used by DataTables.
Allan