| Page 1 of 1 | [ 4 posts ] |
|
I want to set up a DataTable that scrolls both horizontally and vertically. But I want the Height of the table to be set up on load time based on the available height of the browser. I am trying to override the doBeforeLoadData() to do this, but I am not having much luck. I am a beginner to YUI and I am just taking the examples and expanding them. Any help would be greatly appreciated.
Thank you |
|
Read http://developer.yahoo.com/yui/datatable/
Specifically (these are "pull quotes" from the above link): 1. "The 2.6.0 release of DataTable introduces the ScrollingDataTable" 2. http://developer.yahoo.com/yui/datatable/#scrolling which includes this: "To enable scrolling, call the YAHOO.widget.ScrollingDataTable constructor and define width and/or height String values. X-scrolling is enabled by only setting a width, y-scrolling is enabled by only setting a height, and xy-scrolling is enabled by setting both. When a height is set, it defines the height of the vertically scrolling body of the table, not including headers." So presumably you could set the height of the y-scrolling to the screen height (or whatever) and you'd be good to go. (Note: I have not tested this.) |
|
To enable scrolling just set your height or width (or both).
If you want to set the height based on the viewport, then use getViewportHeight in the DOM collection. You can put this into your actual table definition like so: myDataTable = new YAHOO.widget.DataTable("container", columnDefs, dataSource, { scrollable:true, height: (YAHOO.util.Dom.getViewPortHeight()) + "px", width:"100%", initialRequest: EventViewer.requestBuilder(), formatRow: EventViewer.rowFormatter }); You'll need to subtract something from the viewportheight to make it look nicer, just experiment with different values. Or you can set the height after rendering the table, remembering that data is fetched asyncronously so it should be quick enough to not see the original height: myDataTable.set('height', (YAHOO.util.Dom.getViewPortHeight()) + 'px'); That should do you, if your table is inside a layout object you need to use something else, so let me know if that is the case. Also if you have hybridised your code to have 2.x and 3.x functions, the 3.x getViewPort is slightly different. |
|
Richard suggests using:
height: (YAHOO.util.Dom.getViewPortHeight()) + "px", This produces the error: Error: YAHOO.util.Dom.getViewPortHeight is not a function The code should read: height: (YAHOO.util.Dom.getViewportHeight()) + "px", |
| Page 1 of 1 | [ 4 posts ] |
| 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