Tuesday, May 17, 2011

DataGrid Row Heights


This article demonstrates using the DataGrid rowHeight and variableRowHeights property to the height of grid rows.

By default all of the rows in a DataGrid have the same height.  The rows' heights are defined by the rowHeight property and if its value is not specified, the computed "preferred" height of the first row is used.   If the variableRowHeight property is set to true, then the height of each row is the maximum measured height of each cell that's been exposed, so far.  That means that when the DataGrid's columns aren't all visible and variableRowHeight="true",  scrolling new columns into view can cause a row's height to grow.   Similarly, the DataGrid uses the first row's height (or the rendered height of the "typcalItem", if it was specified) as an estimate for the heights of rows that haven't been scrolled into view yet.   This means that the DataGrid Grid's contentHeight, i.e. total height of all of the rows, can grow or even  shrink as it's scrolled, when variableRowHeight=true.  Since the scrollbar's thumb size reflects the content size, you may see its height change a little as you scroll, although as the number of rows gets large, this effect usually isn't noticeable.

Here's a simple example and the source code.  When variableRowHeight="false" (the default) use the slider to change the row height of all the DataGrid's rows. When variableRowHeight="true", each row's height is computed.   With the variableRowHeight checkbox checked, try adding enough text to a string in the  "name" column to cause the renderer to wrap, or resize the column's width by dragging  the header's column separators.
Note that if there's additional vertical space left over after all the rows have been displayed, DataGrid displays row and column separators that indicate empty or "padding" rows at the bottom of the grid.  The padding rows do not contain item renderers and the DataGrid doesn't provide any feedback or support selection for padding rows.   They just exist to show the user the limits of the grid.  The padding rows' height is always the most recent value of rowHeight.

The runtime support for variable height rows requires quite a bit more bookeeping than the  variableRowHeight="false" case and there's a commensurate impact on performance and footprint. That's why by default the DataGrid is configured for fixed height rows.   That said, item renderer complexity tends have a much bigger impact on display/scrolling performance, so developers need not shy away from specifying variableRowHeight=true, even when optimizing for performance.

If you take a look at the source code for this example, you'll see that the slider and label are not bound to the DataGrid's rowHeight property, but to "dataGrid.grid.rowHeight".  The grid is an instance of Grid that's responsible for displaying the cells' item renderers,  and all of the other grid visuals, like the selection and hover indicators.  Many DataGrid properties, like rowHeight, are just "covers" that expose the corresponding Grid property. Generally speaking there's no need to be aware of this however in this case the DataGrid cover property doesn't dispatch binding change events when the corresponding Grid property changes.   This limitation should be corrected in a future release.

30 comments:

  1. I know this is an old post but it brings up some questions related to variableRowHeight and any layout.

    With large variances in individual row heights for a VerticalLayout, how could one correct incorrect setting of the verticalScrollPosition so that items in the view don't jump on the user when rows are added or deleted in a virtualized list?

    This is a highly tricky thing and if one were to use a list to display anything complex (say a facebook feed with large varying heights), they would run into it immediately.

    I think this is related to the indices in view being changed on the layout. When new itemRenderers are added to the view, the position of itemRenderers that are still in view jump and are incorrectly positioned.

    I imagine that the layout needs to consider when that change happens and reset the verticalScrollPosition to where it should be so that items don't appear to move.

    Any thoughts on that? After scouring the bug database it seems you were the person in the know there, even though evtim (?) did the layout work. :)

    ReplyDelete
  2. I came across this post as well in a search. I'm noticing that if I set variable row height to true, have one row, and if that row's data exceeds the height of the datagrid, I don't get to scroll. Any ideas for that?

    ReplyDelete
  3. Thanks for posting this blog. This was very interesting blog, I felt comfortable while reading this post, thank you........................Please Click here to know more about Oracle Fusion Financials Training details

    ReplyDelete
  4. Thank you for providing useful information and this is the best article blog for the students.learn Oracle Fusion Financials Online Training.

    Oracle Fusion Financials Online Training

    ReplyDelete
  5. Thank you for sharing such a valuable article with good information containing in this blog.learn Oracle Fusion Technical Online Training.

    Oracle Fusion Technical Online Training

    ReplyDelete
  6. Thanks for sharing valuable information in the article.students can make a good career by learning Oracle Fusion SCM Online Training.

    Oracle Fusion SCM Online Training

    ReplyDelete
  7. Thanks for providing such a great information in the blog and also very helpful to all.learn best Oracle Fusion HCM Online Training.

    Oracle Fusion HCM Online Training

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Thank you for sharing such a nice and interesting blog with us. I have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information.
    Oracle Fusion Financials Online Training

    ReplyDelete
  10. Very interesting blog Awesome post. your article is really informative and helpful for me and other bloggers too
    Oracle Fusion HCM Online Training

    ReplyDelete
  11. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.
    Oracle Fusion Technical Online Training

    ReplyDelete
  12. Such a nice blog, I really like what you write in this blog, I also have some relevant Information about if you want more information.
    Oracle Fusion Financials Online Training

    ReplyDelete
  13. Awesome post. your article is really informative and helpful for me and other bloggers too
    Oracle Fusion SCM Online Training

    ReplyDelete
  14. Hey Really Thanks for sharing the best information regarding oracle,hope you will write more great blogs.
    Oracle Fusion HCM Online Training

    ReplyDelete
  15. Thank you for this post.This is very interesting information for me. research topic in economics.

    ReplyDelete
  16. Interesting information and attractive.This blog is really rocking... Yes, the post is very interesting and I really like it.I never seen articles like this. I meant it's so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job.
    Kindly visit us @
    Sathya Online Shopping
    Online AC Price | Air Conditioner Online | AC Offers Online | AC Online Shopping
    Inverter AC | Best Inverter AC | Inverter Split AC
    Buy Split AC Online | Best Split AC | Split AC Online
    LED TV Sale | Buy LED TV Online | Smart LED TV | LED TV Price
    Laptop Price | Laptops for Sale | Buy Laptop | Buy Laptop Online
    Full HD TV Price | LED HD TV Price
    Buy Ultra HD TV | Buy Ultra HD TV Online
    Buy Mobile Online | Buy Smartphone Online in India

    ReplyDelete
  17. Thank you for sharing your awesome and valuable article this is the best blog for the students they can also learn.

    Workday Online Training

    ReplyDelete
  18. A very good article. Thanks to the author. It is very important to support and help students. Who can do my homework for me ?

    ReplyDelete
  19. Thank you for sharing your awesome and valuable article this is the best blog for the students they can also learn.

    Workday Online Training

    ReplyDelete
  20. A befuddling web diary I visit this blog, it's incredibly grand. Strangely, in this present blog's substance made motivation behind fact and sensible. The substance of information is instructive
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  21. The article is very interesting and very understood to be read, may be useful for the people. I wanted to thank you for this great read!! I definitely enjoyed every little bit of it. I have to bookmarked to check out new stuff on your post. Thanks for sharing the information keep updating, looking forward for more posts..
    Kindly visit us @ Madurai Travels | Best Travels in Madurai | Cabs in Madurai
    Tours and Travels in Madurai

    ReplyDelete
  22. Excellent Blog. I really want to admire the quality of this post. I like the way of your presentation of ideas, views and valuable content. No doubt you are doing great work. I’ll be waiting for your next post. Thanks .Keep it up!
    Kindly visit us @
    Luxury Packaging Box
    Wallet Box
    Perfume Box Manufacturer
    Candle Packaging Boxes
    Luxury Leather Box
    Luxury Clothes Box
    Luxury Cosmetics Box
    Shoe Box Manufacturer
    Luxury Watch Box

    ReplyDelete
  23. An astounding web diary I visit this blog, it's inconceivably magnificent. Strangely, in this current blog's substance made point of fact and sensible. The substance of information is instructive.
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  24. Really excellent information and thank you for giving your valuable information

    Workday HCM Online Training

    ReplyDelete
  25. It's Incredibly grand. Really very helpful article , Thank you for sharing

    Workday Online Training

    ReplyDelete
  26. Very interesting blog I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.

    Workday HCM Online Training

    ReplyDelete