CellTable + Editor displaying only those rows based on a flag in the bean

19 views
Skip to first unread message

Kamsonline

unread,
Aug 12, 2011, 12:50:51 AM8/12/11
to Google Web Toolkit
Hi,

I am not sure whether any solution posted regarding this, but I
couldn't find any.

I am using GWT + MVP + Editor + Celltable.

I am trying to display a list of objects in the cell table using
editors and I want to display only those beans (rows) based on a flag
set in the bean itself. For ex.

if the bean is User

User { // This is just an example
Long id;
String Name;
String role;
boolean active;
}

I want to display a list of user records in a celltable using editors.
But i want to restrict what is displayed based on the active flag. say
for example, display the user in the table only if they are active.

Any suggestions how i can accomplish this?

Thanks in advance

Uemit

unread,
Aug 22, 2011, 4:57:02 AM8/22/11
to google-we...@googlegroups.com
You will probably use an AbstractDataProvider instance to fill the CellTable. You have to create a helper method which retrieves the list of beans based on the flag and sets it in the AbstractDataProvider (or ListDataProvider). 
Something like this:

final ListDataProvider<User> dataProvider = new ListDataProvider<User>();
List<User> listToDisplay = new ArrayList<User>();
for (User user: userList) {
    if (user.isActive())
       listToDisplay.add(user);
}
dataProvider.setList(listToDisplay);
dataProvider.addDataDisplay(cellList);

Reply all
Reply to author
Forward
0 new messages