| Page 1 of 2 | [ 13 posts ] | Go to page 1, 2 Next |
|
Hi,
Recently I have started using the YUI. I am slowly working my way thro the examples provided and the API documentation. I got the DataTable working OK with a Data Source. However, I cant seem to initialise the column width. I am providing the code I have below. Can anyone tell me where I am going wrong? Code: function DispayDataTable ( sURL, sDiv ) { var myColumnDefs = [ {key:"C1",resizeable:true,width:"50em"}, {key:"C2",resizeable:true,width:"50em"}, {key:"C3",resizeable:true,width:"50em"}, {key:"C4",resizeable:true,width:"200em"}, {key:"C5",resizeable:true,width:"50em"}, {key:"C6",resizeable:true,width:"200em"} ]; var myDataSource = new YAHOO.util.DataSource(sURL); myDataSource.responseType = YAHOO.util.DataSource.TYPE_TEXT; myDataSource.responseSchema = { recordDelim: "\n", fieldDelim: "|", fields: [ "C1", "C2", "C3", "C4", "C5", "C6"] }; var myDataTable = new YAHOO.widget.DataTable ( sDiv, myColumnDefs, myDataSource, {caption:"Data Table Test"}); myDataTable.render; } I just tried with 50em and 50px but nothing seems to work. Any help much appreciated! |
|
Widths have to be in pixels or plain integers which will be assumed to be pixels.
|
|
Thanks for your reply. I changed it to normal integers and it still automatically sets the width!! Any other thing I can try?
|
|
|
|
Just to clarify, it should be
width:50 not width:"50" |
|
Doh!! Thanks very much. Works now
|
|
Specified column widths for a YUI DataTable that has the table's CSS property "width: 100%" fails. These specified columns remain auto-sized (the th and td tag widths are not set).
Does anyone know of a way to make a DataTable's width expand to 100%, specify the column width for certain columns, and allow other columns' width to be auto-sized? |
|
After scouring the web, it appears that the question in my previous post has been a long sought after by lot's of folks. Not even the YUI dev's have been able to offer an answer.
It's a good thing I showed up to save the day. To get a table stretched to 100% of it's container div, while still maintaining specified column widths, do this: 1. Set the CSS property "width: 100%" for either the DataTable's table tag, or the div that contains the DataTable. 2. Set the "width" DataTable column property to the number of pixels you want specifically per column. 3. Set the "minWidth" DataTable column property to a ridiculously enormous number per columns you want auto-sized. Example: Code: var myColumnDefs = [ {key:"foo", width: 20}, {key:"bar", minWidth: 999999 }, ]; new YAHOO.widget.DataTable("someContainer", myColumnDefs, myDataSource); Tested using YUI 2.7.0 with FF3 and IE7. |
|
Unfortunately this does not work at Chrome 4.1
|
|
Correction: it works perfectly with Chrome too! Awesome!
|
| Page 1 of 2 | [ 13 posts ] | Go to page 1, 2 Next |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group