A better approach to dynamic columns/ FixedColumns
A better approach to dynamic columns/ FixedColumns
The URL to my example :
http://live.datatables.net/edeheh/4/
Be aware that I am asking multiple questions based on this example.
The example uses a static JSON object to populate the table, normally this data would come from a database and be anywhere from 1-300 columns. So I used a previous post suggestion using aoColumns, and gave the additional information it needed like sClass.
I also need to render the cells content from a value to a color/character ( method convertValueToColor), I was able to use aoColumnDefs to handle that problem.
So what I have as a dataTable constructor is :
var oTable = $('#example').dataTable({
"aaData": data.aaData,
'iDisplayLength': 25,
"oLanguage": {
"sLengthMenu": 'Display '+
'25'+
'All'+
' records'
},
"sScrollX": "100%",
"bPaginate": true,
"bScrollCollapse": true,
"aoColumnDefs": [ {
"aTargets": columnLength,
"mRender": function ( data, type, full ) {
return (convertValueToColor(data, full[0]));
}
} ],
"aoColumns": data.aoColumns
});
var fcObj = new FixedColumns( oTable , { "iLeftColumns": 1 } );
So this works, but it's not pretty and I believe it is also is giving the FixedColumns plugin heartburn. See the demo for the strange behavior.
1. Any suggestions 'merging' the aoColumns and aoColumnDefs sections? Should that cause a problem with the plugins?
2. Any ideas how to fix the FixedColumns double 'printing' the Date Column?
What I'm really after is mimic freezing the left column like in this example: http://datatables.net/release-datatables/extras/FixedColumns/index.html
Thanks.
http://live.datatables.net/edeheh/4/
Be aware that I am asking multiple questions based on this example.
The example uses a static JSON object to populate the table, normally this data would come from a database and be anywhere from 1-300 columns. So I used a previous post suggestion using aoColumns, and gave the additional information it needed like sClass.
I also need to render the cells content from a value to a color/character ( method convertValueToColor), I was able to use aoColumnDefs to handle that problem.
So what I have as a dataTable constructor is :
var oTable = $('#example').dataTable({
"aaData": data.aaData,
'iDisplayLength': 25,
"oLanguage": {
"sLengthMenu": 'Display '+
'25'+
'All'+
' records'
},
"sScrollX": "100%",
"bPaginate": true,
"bScrollCollapse": true,
"aoColumnDefs": [ {
"aTargets": columnLength,
"mRender": function ( data, type, full ) {
return (convertValueToColor(data, full[0]));
}
} ],
"aoColumns": data.aoColumns
});
var fcObj = new FixedColumns( oTable , { "iLeftColumns": 1 } );
So this works, but it's not pretty and I believe it is also is giving the FixedColumns plugin heartburn. See the demo for the strange behavior.
1. Any suggestions 'merging' the aoColumns and aoColumnDefs sections? Should that cause a problem with the plugins?
2. Any ideas how to fix the FixedColumns double 'printing' the Date Column?
What I'm really after is mimic freezing the left column like in this example: http://datatables.net/release-datatables/extras/FixedColumns/index.html
Thanks.
This discussion has been closed.