Fixing more than one left column?
Fixing more than one left column?
Wodin
Posts: 17Questions: 0Answers: 0
FixedHeader seems to work pretty well for my needs as long as I use it with DataTables and not with:[code]document.getElementById("blah")[/code]
but I need to fix two left columns instead of just one.
How hard would it be to do this using FixedHeader?
Thanks.
but I need to fix two left columns instead of just one.
How hard would it be to do this using FixedHeader?
Thanks.
This discussion has been closed.
Replies
FixedColumns (for when the table is scrollable) however does support that: http://datatables.net/release-datatables/extras/FixedColumns/two_columns.html .
Allan
Perhaps if you point me in the right direction I'll be able to figure out how to make FixedHeaders able to fix more than one column?
Allan
I had a brief look at the _fnCloneTLeft function yesterday. Did not understand all of it, but I'll have a better look later today to see if I can hard code it to the two left columns instead of one, which is what I need. If I can figure out how to do it more generically (i.e. allow the user to specify the number of columns) I'll do that instead.
I assume you are using 1.9.0 - there is a bug in that sadly. It is addressed in 1.9.1.dev ( http://datatables.net/download ).
Allan
This seems to do what I want wrt. fixing the 2 left columns (quick'n'dirty), but I suspect I need to do something about the widths too:
[code]@@ -740,12 +738,12 @@ FixedHeader.prototype = {
nTable.appendChild( jQuery("tfoot", s.nTable).clone(true
}
- jQuery('thead tr th:gt(0)', nTable).remove();
- jQuery('tfoot tr th:gt(0)', nTable).remove();
+ jQuery('thead tr th:gt(1)', nTable).remove();
+ jQuery('tfoot tr th:gt(1)', nTable).remove();
/* Remove unneeded cells */
$('tbody tr', nTable).each( function (k) {
- $('td, th', this).filter(':gt(0)').remove();
+ $('td, th', this).filter(':gt(1)').remove();
} );
this.fnEqualiseHeights( 'tbody', nBody.parentNode, nTable );
[/code]
after lil playing with the code figure out the hack for this
in _fnCloneTLeft function
change the;
[code]
/* Remove unneeded cells */
$('tbody tr', nTable).each( function (k) {
$('td:gt(0)', this).remove();
} );
[/code]
To ex.;
[code]
$('td:gt(2)', this).remove();
[/code]
Its going to keep first 3 columns in the left, so after each scrolling when the oCache gets updated and first 3 columns gonna stay in place.
same idea can be applied to fixing right columns too ;]
[first I tried updating the cells text after fixedLeft column div gets created but then noticed oCache gets refreshed on every ui scroll, that didn't work]
Thanks Allen for defining the starting point...
[code]
I am in love with DataTables
[/code]