Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8292825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:36:41+00:00 2026-06-08T13:36:41+00:00

Currently GWT DataGrid header does this trick with a fixed header row during a

  • 0

Currently GWT DataGrid header does this trick with a fixed header row during a vertical scroll. Is there a way to acheive the same on an entire (first) column?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:36:42+00:00Added an answer on June 8, 2026 at 1:36 pm

    I have implemented ScrolledGrid that freezes first column in DataGrid. You need to use it instead of DataGrid in order to make first column be frozen.

    import com.google.gwt.dom.client.*;
    import com.google.gwt.event.dom.client.ScrollEvent;
    import com.google.gwt.event.dom.client.ScrollHandler;
    import com.google.gwt.user.cellview.client.DataGrid;
    import com.google.gwt.user.client.ui.HeaderPanel;
    import com.google.gwt.user.client.ui.ScrollPanel;
    
    /**
     *
     * @author Yuri Plaksyuk
     */
    public class ScrolledGrid extends DataGrid {
    
        private final Text cssText;
        private boolean addedClass = false;
        private int currentScrollLeft = 0;
    
        public ScrolledGrid() {
            cssText = Document.get().createTextNode("");
    
            StyleElement styleElement = Document.get().createStyleElement();
            styleElement.setType("text/css");
            styleElement.appendChild(cssText);
    
            HeaderPanel headerPanel = (HeaderPanel) getWidget();
            headerPanel.getElement().insertFirst(styleElement);
    
            final ScrollPanel scrollPanel = (ScrollPanel) headerPanel.getContentWidget();
            scrollPanel.addScrollHandler(new ScrollHandler() {
    
                @Override
                public void onScroll(ScrollEvent event) {
                    int scrollLeft = scrollPanel.getHorizontalScrollPosition();
                    if (scrollLeft != currentScrollLeft) {
                        StringBuilder css = new StringBuilder();
                        if (scrollLeft > 0) {
                            css.append(".ScrolledGrid-frozen {");
                            css.append("background-color: inherit;");
                            css.append("}");
    
                            css.append(".ScrolledGrid-frozen div {");
                            css.append("position: absolute;");
                            css.append("left: ").append(scrollLeft).append("px;");
                            css.append("width: ").append(getColumnWidth(getColumn(0))).append(";");
                            css.append("padding-left: 1.3em;");
                            css.append("padding-right: 0.5em;");
                            css.append("margin-top: -0.7em;");
                            css.append("white-space: nowrap;");
                            css.append("background-color: inherit;");
                            css.append("}");
                        }
                        else
                            css.append(".ScrolledGrid-frozen { }");
    
                        css.append("th.ScrolledGrid-frozen { background-color: white; }");
    
                        cssText.setData(css.toString());
    
    
                        if (!addedClass) {
                            NodeList<TableRowElement> rows;
                            TableRowElement row;
                            TableCellElement cell;
    
                            rows = getTableHeadElement().getRows();
                            for (int i = 0; i < rows.getLength(); ++i) {
                                row = rows.getItem(i);
                                cell = row.getCells().getItem(0);
                                cell.setInnerHTML("<div>" + cell.getInnerHTML() + "</div>");
                                cell.addClassName("ScrolledGrid-frozen");
                            }
    
                            rows = getTableBodyElement().getRows();
                            for (int i = 0; i < rows.getLength(); ++i) {
                                row = rows.getItem(i);
                                cell = row.getCells().getItem(0);
    
                                cell.addClassName("ScrolledGrid-frozen");
                            }
                            addedClass = true;
                        }
    
                        currentScrollLeft = scrollLeft;
                    }
                }
            });
        }
    }
    

    Unfortunately, some CSS values are hard-coded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to VIEW the HTML source code that GWT produces? Currently
Currently I use the JavaScript code to send XML data in GWT. Is there
Is there a way to set padding on GWT's HorizontalPanel ? I wanted to
Is there any way to set gwt compiler so that each permutation is compiled
Currently our application uses GWT-RPC for most client-server communication. Where this breaks down is
There's a GWT application that uses GWT Places/Activities facility. There's also a servlet (currently,
I want to use jquery SlickGrid in gwt. Has anybody tried this ? Currently
I am currently using GWT's built in logger, however the way it is attached
I am designing a web application using GWT currently, which is also the first
I'm currently making a GWT project where I display some HTML in a RichTextArea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.