"sScrollY": 800,
"bAutoWidth": false,
"bDeferRender": true,
"bFilter": true,
"bSort": true,
"fnRowCallback": function (nRow, aData) {
// Customer column class
jQuery("td:eq(4)", nRow).addClass("name_column");
},
"fnInitComplete": function () {
// Adjust scroll areas for table
adjustTable();
}
adjustTable = function () {
var wrapperHeight = jQuery("#BlockList_Table_wrapper").height();
var headerHeight = jQuery(".dataTables_scrollHead").height();
var infoPadding = 20;
var infoHeight = jQuery("#BlockList_Table_info").height() + infoPadding;
// Adjust scroll area
jQuery(".dataTables_scroll").height(wrapperHeight - infoHeight);
jQuery(".dataTables_scrollBody").height(wrapperHeight - headerHeight - infoHeight);
// Adjust column sizing
bController.bList.fnAdjustColumnSizing();
};
I recently switched out infinite scrolling in favor of the Scroller plug-in, but have experienced some unusual behavior for a variable-height table.
Note that rows in the table must all be the same height. Information in a cell which expands on to multiple lines will cause some odd behaviour in the scrolling.
top: 0; right: 0; left: 0; height: 72pxand the #middle div has
top: 72px; right: 0; bottom: 0; left: 0so that both divs completely fill the screen.
"yScroll" : $("#middle").height()+"px" but only WebKit seems to be correctly filling the entire page with rows. Firefox only appears to be filling about half of that space. I think it has to do with the fact that #middle is absolutely positioned and that it doesn't have an explicitly set height property. I'm guessing that's the issue because it worked fine when I wasn't absolutely positioning the table's wrapper, but it's kind of confusing because after looking through oTable.oOptions I can see a "y" property that is correctly set to 870px (the height of #middle). So it clearly is getting the correct height value, but it's not respecting it.dom.oTable = $("#list").dataTable({
"aaData": Temp.aaData, // Arrays
"aaSorting": [[0,'asc'], [2,'asc'], [1,'asc']],
"aoColumnDefs": [
{ "sType": "song", "aTargets": [ 0, 1, 2, 3 ] },
{ "sType": "numeric", "aTargets": [ 4, 5, 6, 8 ] }
],
"aoColumns": [
{ "sName": "artist", "sClass": "artist" },
{ "sName": "title", "sClass": "title" },
{ "sName": "album", "sClass": "album" },
{ "sName": "genre", "sClass": "genre", "bSortable": false },
{ "sName": "dev-origin-id", "sClass": "source", "bSearchable": false, "bSortable": false, "bVisible": true },
{ "sName": "length", "sClass": "length", "bSearchable": false, "bVisible": true, "fnRender": function (oObj) { return hhmmss(oObj.aData[oObj.iDataColumn]); }, "bUseRendered": false },
{ "sName": "playcount", "sClass": "plays", "bSearchable": false, "bVisible": true },
{ "sName": "idhash", "bSearchable": false, "bVisible": false },
{ "sName": "art", "bSearchable": false, "bVisible": false }
],
"oScroller": { // Objects
"serverWait": 100,
"trace": false
}
"bScrollAutoCss": true, // Booleans
"bDestroy": true,
"bInfo": false,
"bAutoWidth": true,
"bDeferRender": true,
"bProcessing": false,
"bRetrieve": true,
"bStateSave": true,
"iScrollLoadGap": 100, // Integers
"iDisplayLength": 200,
"sDom": "RtrS", // Strings
"sScrollY": $('#middle').height()+'px',
// Functions
"fnStateSave": function (oSettings, oData) { localStorage.setItem('oData', JSON.stringify(oData)); },
"fnStateLoad": function (oSettings) { return JSON.parse(localStorage.getItem('oData')); },
});
@navbarHeight: 72px;
#top {
position: absolute;
top: 0; right: 0; left: 0;
height: @navbarHeight;
box-shadow: 0 -1px 0 black inset, 0 -2px 0 rgba(255,255,255,.2) inset;
}
#middle {
position: absolute;
top: @navbarHeight; right: 0; bottom: 0; left: 0;
div#list_wrapper { // DataTable wrapper
width: 100%;
height: 100%;
.dataTables_scroll { // Scroller wrapper
.box-sizing(border-box); // Adds vendor prefixes
width: 100%;
height: 100% !important // Override inline styles
position: relative;
}
.dataTables_scrollHead { // Faux fixed header wrapper
position: absolute;
z-index: 99999;
height: 33px;
overflow: visible;
.dataTables_scrollHeadInner { // Inner wrapper for header
width: 100% !important; // Override inline styles
}
}
.dataTables_scrollBody { // Real table with tbody content
height: 100% !important // Override inline styles
thead { display: none } // No need to have two header rows
}
td.plays, // Force correct widths for columns
td.length,
td.source { width: 6% !important; }
td.genre { width: 10% !important; }
td.album { width: 24% !important; }
td.title { width: 24% !important; }
td.artist { width: 24% !important; }
th.plays, // Could do this in one step if DataTables
th.length, // used <col>s inside a <colgroup>
th.source { width: 6% !important; } // by only setting the width on each <col>
th.genre { width: 10% !important; }
th.album { width: 24% !important; }
th.title { width: 24% !important; }
th.artist { width: 24% !important; }
}
} this.s.viewportHeight = $("#middle").height(); Obviously, that isn't a solution worth committing, but it fixed my problem. It looks like you're new here. If you want to get involved, click one of these buttons!
Get useful and friendly help straight from the source.