FixedColumns and extra data
FixedColumns and extra data
norglaw
Posts: 9Questions: 0Answers: 0
Datatables and its plugins and extras are really great.
In order to navigate from the table to some detailed page, I added a hidden column with a URL for each row and a click event listener in the fnDrawCallback (unless the td has a rowselect class).
Here is the callback code:
[code]
"fnDrawCallback": function(oSetting) {
$(oSetting.aoData).each(function(index, element){
var colLienIndex = 2 ;
$(element.nTr).children('td:not(:has(.rowselect))').unbind('click');
$(element.nTr).children('td:not(:has(.rowselect))').click(function(event){
if (event.ctrlKey)
window.open(element._aData[colLienIndex]);
else
location.href = element._aData[colLienIndex];
});
});
},
[/code]
And here is a sample of the aaData:
[code]
[ "Dussillols Corinne","2255383","?mod=prestations&view=facture&action=detail&id=9","Pharmacie Agen Sud","AGEN","0,00","0,00","0,00"],
[ "Wagner Philippe","","?mod=prestations&view=facture&action=detail&id=10","Pharmacie de la Place ","FALCK","0,00","0,00","0,00"],
[ "Antoine Monique","2146974","?mod=prestations&view=facture&action=detail&id=11","Pharmacie Antoine-Appel","SARREGUEMINES","0,00","0,00","0,00"]
[/code]
As I have now lots of columns, I added the good FixedColumns extra.
The problem is that the left fixed column is not part of the nTr nodes.
So, I thought to add some code in the fixed columns fnDrawCallback itself but I don't know how to link with to the extra data stored in the hidden column.
Would someone have an idea ?
Thank you.
In order to navigate from the table to some detailed page, I added a hidden column with a URL for each row and a click event listener in the fnDrawCallback (unless the td has a rowselect class).
Here is the callback code:
[code]
"fnDrawCallback": function(oSetting) {
$(oSetting.aoData).each(function(index, element){
var colLienIndex = 2 ;
$(element.nTr).children('td:not(:has(.rowselect))').unbind('click');
$(element.nTr).children('td:not(:has(.rowselect))').click(function(event){
if (event.ctrlKey)
window.open(element._aData[colLienIndex]);
else
location.href = element._aData[colLienIndex];
});
});
},
[/code]
And here is a sample of the aaData:
[code]
[ "Dussillols Corinne","2255383","?mod=prestations&view=facture&action=detail&id=9","Pharmacie Agen Sud","AGEN","0,00","0,00","0,00"],
[ "Wagner Philippe","","?mod=prestations&view=facture&action=detail&id=10","Pharmacie de la Place ","FALCK","0,00","0,00","0,00"],
[ "Antoine Monique","2146974","?mod=prestations&view=facture&action=detail&id=11","Pharmacie Antoine-Appel","SARREGUEMINES","0,00","0,00","0,00"]
[/code]
As I have now lots of columns, I added the good FixedColumns extra.
The problem is that the left fixed column is not part of the nTr nodes.
So, I thought to add some code in the fixed columns fnDrawCallback itself but I don't know how to link with to the extra data stored in the hidden column.
Would someone have an idea ?
Thank you.
This discussion has been closed.