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 8023375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:32:53+00:00 2026-06-04T22:32:53+00:00

Working on a GWT app that needs something like a CellTable to display and

  • 0

Working on a GWT app that needs something like a CellTable to display and edit data. The extra requirements I have that I have not seen covered in CellTable examples:

  • Multiple header rows. I don’t really need a header row as such, but every few rows (4-10) of data I’d like something like a header (basically explains how the next ‘n’ items are related)

  • Based on some data (current date and dates specified in an object), some of the fields should be non editable. I’ve found examples on how to make a column non editable, but how do I map that back through to actual data from the custom renderer? (i.e. the data object corresponding to the row – should be easy, but I’m missing something…)

Can I do this with the CellTable? Is there a better Widget I should be looking at? I know I could do it all in a Grid, but the CellTable looks much better!

Thanks.

Answer

Expanding on Thomas Broyer’s answer below I’ve managed to get the non editable stuff going. I never really expected the “header rows” to be easy, so the editing was the main part.

As I commented below, I didn’t find any simple, easy to follow example that showed me the whole picture. I managed to piece it together from a few different sources.

If anyone has any comments or I’ve missed something obvious: let me know!

// Step 1: Create a cell (in this case based on text)
class MyEditTextCell extends EditTextCell {
    @Override
    public void render(com.google.gwt.cell.client.Cell.Context context,
            String value, SafeHtmlBuilder sb) 
    {
        bool editable = true;
        // TODO: What goes here?

        if (!editable) {
        sb.appendHtmlConstant("<div contentEditable='false' unselectable='true'>" + value + "</div>");
    }
    else {
            super.render(context, value, sb);
        }
    }
}

// It gets used to add a column to the table like this
final MyEditTextCell myCell = new MyTextCell();
Column<RowType, String> nmyCol = new Column<RowType, String>(myCell) {
    @Override
    public String getValue(RowType o) {
        return o.someMethod(); // This gets the particular row out of your column.
    }
};
table.addColumn(myCol, "Heading");

So all of that worked fairly easily, but I still couldn’t figure out the TODO of using the row. It all cam together with another example that dealt with KeyProviders. The KeyProvider provides a link from the Context you get in the render() method of the cell and the row that the cell belongs to. It does this via an index (which is just an Object).

So you end up with:

// Step 2: Cell can get the row and use it to decide how to draw.
class MyEditTextCell extends EditTextCell {
    @Override
    public void render(com.google.gwt.cell.client.Cell.Context context,
            String value, SafeHtmlBuilder sb) 
    {
        Object key = context.getKey();
        // What the key is is uo to you: if could be an Integer that indexes into
        // a collection of objects, it could be a key for a hashmap. I'm guessing
        // it could even be the real object itself (but I haven't tried that...)
        // e.g.
        boolean editable = true;
        int index = ((Integer)key).intValue();
        RowType row = myRowCollection.get(index);
        if (row != null) {
            if (/*some condition on the row*/) {
                editable = false;
            }
        }
        if (!editable) {
        sb.appendHtmlConstant("<div contentEditable='false' unselectable='true'>" + value + "</div>");
    }
    else {
            super.render(context, value, sb);
        }
    }
}

// Key provider links gets a unique id from the rows - I just used an in.
// This gets provided to the CellTable on creation
// e.g. CellTable tab = new CellTable(LEY_PROVIDER);
//
private static final ProvidesKey<RowType> KEY_PROVIDER = new ProvidesKey<RowType>() {
    public Object getKey(RowType item) {
        return Integer.valueOf(item.getId());
    }
};
  • 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-04T22:32:54+00:00Added an answer on June 4, 2026 at 10:32 pm
    • Multiple header rows. I don’t really need a header row as such, but every few rows (4-10) of data I’d like something like a header (basically explains how the next ‘n’ items are related)

    (aka grouping rows)
    GWT 2.5 (to be released in a month or so) will add CellTableBuilder which lets you change how CellTable builds its view from its model.
    You can see an example in action here (not the same use-case as yours though: adds child rows rather than grouping rows): http://showcase2.jlabanca-testing.appspot.com/#!CwCustomDataGrid
    In your case, the tricky part is to detect when to insert a grouping row.

    • Based on some data (current date and dates specified in an object), some of the fields should be non editable. I’ve found examples on how to make a column non editable, but how do I map that back through to actual data from the custom renderer? (i.e. the data object corresponding to the row – should be easy, but I’m missing something…)

    Your best bet is to use a custom Cell that takes a row object value (so it can decide whether the cell should be editable) but only displays/edits a field/property of that object.
    You should be able to defer the rendering and event handling to either a TextInputCell or EditTextCell if the value is editable, and a TextCell otherwise.

    The tricky part is if the condition to make the column editable depends on properties that are themselves editable. In that case, you’d have to trigger a refresh of the table (at least the modified row) so the conditionally editable column is refreshed.
    In that case, I think you’d have better chances by using a custom Cell that always renders the same initially but can switch to editable mode (similar to EditTextCell); and do the is that value editable computation when handling the event, and conditionally refuse to switch to edit mode.
    You should be able to copy/paste a lot from EditTextCell here.

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

Sidebar

Related Questions

I am working on a GWT app that needs to serve a different layout
I am working with GWT and have 4 Service Implementations that need a PersistenceManagerFactory.
I have a strange issue in my GWT app. My application is working fine
I'm working on a GWT app that's using Google Maps. I'm trying to add
I have been working with GWT projects, and the scenario with GWT is that
I have a GWT app (generated by roo) that I have decided to secure
I have a working GWT-App Engine web project which works before I added the
Right so i am working with hibernate gilead and gwt to persist my data
I am trying to get my fancy CSS3 redesign working for a GWT app,
I am working to create a Java based web app that also has ability

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.