views:

770

answers:

6

This may seem like a basic question, but I'm having trouble figuring out how to set the table width to 100% on a YUI datatable.

I tried doing

#dtContainer {
    width: 100%;
}

#dtContainer table {
    width: 100%
}

but none of these approaches work.

To clarify, I am trying to set the datatable width to 100% when the table is empty and the empty message is displayed.

The generated table is an HTML table; so, I thought this should work. Thanks, Abe

+1  A: 

this is an ugly solution. but it works

<script>
window.onload = function() {
setTimeout('document.getElementById("NAME OF CONTAINER DIV").childNodes[1].style.width
= "100%"',1000);
};
</script>

the problem is applying the style pre render is pointless, the javascript is building the table, post render is all I could get to work.

Singularity
Thanks. I didn't use your implementation, but it did point me in the right direction.I basically used the YUI Dom method setAttribute to set the size on methods that triggers the render() event on the YUI datatable.
AbeP
+3  A: 

It turns out the solution is really simple:

.yui-dt table
{
    width: 100%;
}
AbeP
Sorry, forgot to mention that I did not use this solution...
AbeP
A: 

looks like this little style tag works magic:

 .yui-dt table { width:100%;}
Singularity
A: 

.yui-dt table { width:100%;}, .yui-dt table { width: 100%; }, doesn't work correctly.

Maksim
A: 

table displayed out of document flow, when I using .yui-dt table { width:100%;} style. (ie6, ie7, ie8, ff3, yui dataTable-min(version 2.8))

Maksim
+2  A: 

Dont use .yui-dt table { width:100%;} , It doesn't appear to set the column widths correctly. Use myDataTable.setAttributes({width:"100%"},true); after table render

Matt Calderaro
Yep. that's what I did in the render event. thanks!
AbeP
worked for me. also added the following on postRender so the header and body would alight right: $("div.yui-dt-hd").css('width', 'auto'); $("div.yui-dt-bd").css('width', 'auto');
krefftc