[ 4 posts ]

Eve Nebenhaus

  • Username: ever51
  • Joined: Thu Feb 12, 2009 9:23 am
  • Posts: 2
  • Offline
  • Profile

DataTable scrolling-y

Post Posted: Thu Feb 12, 2009 3:07 pm
+0-
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

K o v a c s

  • Username: Kovacs
  • Joined: Wed Feb 11, 2009 8:55 am
  • Posts: 100
  • Location: The Biggest Little City in the World
  • Offline
  • Profile

Re: DataTable scrolling-y

Post Posted: Sat Feb 21, 2009 10:05 pm
+0-
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.)

richardbenson

  • Joined: Wed Feb 11, 2009 6:17 am
  • Posts: 31
  • Offline
  • Profile

Re: DataTable scrolling-y

Post Posted: Fri Feb 27, 2009 2:01 am
+0-
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.

Ian Nicholson

  • Username: INicholson
  • Joined: Thu Mar 26, 2009 10:53 am
  • Posts: 1
  • Offline
  • Profile
Tags:

Re: DataTable scrolling-y

Post Posted: Thu Mar 26, 2009 11:09 am
+0-
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",
  [ 4 posts ]
Display posts from previous:  Sort by  
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