Vertical scrollbar width not factored into header width
Vertical scrollbar width not factored into header width
WeaponX86
Posts: 40Questions: 0Answers: 0
Using 1.9.0 Feb 1st 2012
I need vertical and horizontal scrollbars, and the datagrid will be fluid horizontally. The issue is compounded when I try to add padding to the header or body cells.
Scrolling all the way right:
http://i.imgur.com/dZ1to.jpg
Scrolling almost all the way right:
http://i.imgur.com/aOosR.jpg
Live example:
http://dev.propertypreswizard.com/test_scripts/beta/data.html
Initialization:
[code]
var oTable = $('#work_orders').dataTable({
"sScrollX": "100%",
"sScrollY": "400px",
//"bPaginate": false,
//"sScrollXInner": "100%",
//"bScrollCollapse": true,
"iDisplayLength": 50,
"bFilter": true,
"bSort": true,
"sDom": '<"form-header clearfix"lf>rt<"form-footer clearfix"ip>',
"aLengthMenu": [50,100,250,500],
"sPaginationType": "full_numbers",
"aaData": flatten_assoc(json_arr),
"aoColumns": aoColumns
});
[/code]
CSS:
[code]
/*********************************
* jQuery DataTables
**********************************/
.dataTables_length {
float: left;
width: 40%;
}
.dataTables_filter {
float: right;
text-align: right;
width: 50%;
}
.dataTables_info {
float: left;
width: 50%;
vertical-align: middle;
/*min-height: 100%;*/
/*position: absolute;*/
}
.dataTables_paginate {
float: right;
text-align: right;
}
/* Fix table margin from typography.css */
/*.dataTables_wrapper .dataTable {
margin: 0px;
border-collapse: collapse;
}*/
.dataTables_wrapper .dataTables_scrollHeadInner table{
margin: 0px;
border-collapse: collapse;
}
.dataTables_wrapper .dataTables_scrollHead {
background-color: #e6e6e6;
}
.dataTables_wrapper .dataTables_scrollHeadInner th {
background-color: #e6e6e6;
white-space: nowrap;
/* border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #b2b2b2;*/
border: 1px solid #D3D3D3;
text-align: center;
font-weight: 600;
/* padding-right: 1em;
padding-left: 1em;*/
}
.dataTables_wrapper .dataTables_scrollHeadInner th.sorting_asc {
background-image: url(css/images/sort_asc.png);
background-repeat: no-repeat;
background-position: right center;
}
.dataTables_wrapper .dataTables_scrollHeadInner th.sorting_desc {
background-image: url(css/images/sort_desc.png);
background-repeat: no-repeat;
background-position: right center;
}
.dataTables_wrapper .dataTables_scrollHeadInner th.sorting {
background-image: url(css/images/sort_both.png);
background-repeat: no-repeat;
background-position: right center;
}
.dataTables_wrapper .dataTables_scrollBody td {
white-space: nowrap;
overflow: hidden;
/* padding-right: 1em;
padding-left: 1em;*/
}
[/code]
I need vertical and horizontal scrollbars, and the datagrid will be fluid horizontally. The issue is compounded when I try to add padding to the header or body cells.
Scrolling all the way right:
http://i.imgur.com/dZ1to.jpg
Scrolling almost all the way right:
http://i.imgur.com/aOosR.jpg
Live example:
http://dev.propertypreswizard.com/test_scripts/beta/data.html
Initialization:
[code]
var oTable = $('#work_orders').dataTable({
"sScrollX": "100%",
"sScrollY": "400px",
//"bPaginate": false,
//"sScrollXInner": "100%",
//"bScrollCollapse": true,
"iDisplayLength": 50,
"bFilter": true,
"bSort": true,
"sDom": '<"form-header clearfix"lf>rt<"form-footer clearfix"ip>',
"aLengthMenu": [50,100,250,500],
"sPaginationType": "full_numbers",
"aaData": flatten_assoc(json_arr),
"aoColumns": aoColumns
});
[/code]
CSS:
[code]
/*********************************
* jQuery DataTables
**********************************/
.dataTables_length {
float: left;
width: 40%;
}
.dataTables_filter {
float: right;
text-align: right;
width: 50%;
}
.dataTables_info {
float: left;
width: 50%;
vertical-align: middle;
/*min-height: 100%;*/
/*position: absolute;*/
}
.dataTables_paginate {
float: right;
text-align: right;
}
/* Fix table margin from typography.css */
/*.dataTables_wrapper .dataTable {
margin: 0px;
border-collapse: collapse;
}*/
.dataTables_wrapper .dataTables_scrollHeadInner table{
margin: 0px;
border-collapse: collapse;
}
.dataTables_wrapper .dataTables_scrollHead {
background-color: #e6e6e6;
}
.dataTables_wrapper .dataTables_scrollHeadInner th {
background-color: #e6e6e6;
white-space: nowrap;
/* border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #b2b2b2;*/
border: 1px solid #D3D3D3;
text-align: center;
font-weight: 600;
/* padding-right: 1em;
padding-left: 1em;*/
}
.dataTables_wrapper .dataTables_scrollHeadInner th.sorting_asc {
background-image: url(css/images/sort_asc.png);
background-repeat: no-repeat;
background-position: right center;
}
.dataTables_wrapper .dataTables_scrollHeadInner th.sorting_desc {
background-image: url(css/images/sort_desc.png);
background-repeat: no-repeat;
background-position: right center;
}
.dataTables_wrapper .dataTables_scrollHeadInner th.sorting {
background-image: url(css/images/sort_both.png);
background-repeat: no-repeat;
background-position: right center;
}
.dataTables_wrapper .dataTables_scrollBody td {
white-space: nowrap;
overflow: hidden;
/* padding-right: 1em;
padding-left: 1em;*/
}
[/code]
This discussion has been closed.
Replies
Regards,
Allan
> On a similar note, can I use css to pad the header or will that throw off the alignment? The problem now is the sort indicator overlaps header text.
You can certainly pad the header cells yes (I use that in my own demo CSS).
Allan
I'm still having trouble with padding the cells, in this example I have the following css applied to the header th and body td:
[code]
padding-right: 1.4em;
padding-left: 1.4em;
[/code]
Live example:
http://dev.propertypreswizard.com/test_scripts/beta/data.html
Is there some way I can pad the header cells and have perfect column alignment?
Currently you have:
[code]
.dataTables_wrapper .dataTables_scrollHeadInner th {
[/code]
However, the column width calculation is not done in "dataTables_scrollHeadInner" - its done in with the main table. As such, I think if you do this it should be good:
[code]
.dataTables_wrapper thead th {
[/code]
Allan
Chrome Screenshots:
Scroll all the way left:
http://i.imgur.com/AfJSA.jpg
Scroll all the way right:
http://i.imgur.com/m7dCB.jpg
It seems like it's trying to factor in scrollbar width, but OSX uses ghost scrollbars. Any clues?
Allan
I am facing the same problem, but using nightly js also, it is still not working.
any help would be appreciated.