one way might be to use a List<User> userList private variable in the
widget..
the state of the flextable is same as the state of the userList.

"when a row is selected".. depending on what event selects the row (mouse
over, mouseclick..).. update a private User currentUser object.

public class MyUserListView extends Composite {
    private FlexTable userListTable;
    private ArrayList<User> userList=new ArrayList<User>();
    private User currentSelection;
    public MyUserListView() {
        userListTable=new FlexTable();
        userListTable.setBorderWidth(1);
        DOM.setStyleAttribute(userListTable.getElement(), "cursor",
"pointer");

        initWidget(userListTable);
        userListTable.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                Cell cellClicked= userListTable.getCellForEvent(event);
                int rowIndex=cellClicked.getRowIndex();
                currentSelection=userList.get(rowIndex);
                Window.alert("U have choosen User:
"+currentSelection.getFirstname());

            }
        });
    }
    /**
     * This will mostly be defined in the Presenter view interface.
     * @param u
     */
    public void addUserToUserTable(User u){
        userList.add(u);
        int row=userListTable.getRowCount();
        userListTable.setWidget(row, 0, new HTML(u.getFirstname()));
        userListTable.setWidget(row, 1, new HTML(u.getLastname()));

    }

    public User getCurrentSelection() {
        return currentSelection;
    }



}

in the client class that uses this widget,

MyUserListView mul=new MyUserListView();
        mul.addUserToUserTable(new User("Firstname1","lastname1"));
        mul.addUserToUserTable(new User("Firstname2","lastname2"));
        mul.addUserToUserTable(new User("Firstname3","lastname3"));
        mul.addUserToUserTable(new User("Firstname4","lastname4"));
        mul.addUserToUserTable(new User("Firstname5","lastname5"));
        outerPanel.add(mul);

There are a lot of limitations to this as, u can point out. but it sorts the
basic issue of maintaining the current state of "selected" row. there should
be better ways to handle this. Experts please comment.

Thanks,
Subhro.

On Wed, Jul 7, 2010 at 10:24 PM, Magnus <alpineblas...@googlemail.com>wrote:

> Hi,
>
> I would like to use a FlexTable as a list of users and I need to
> attach a user id to each row somehow, in order to identify the user
> when a row is selected.
>
> I tried to use a column of width "0px", but this column is visible...
>
> How would you do that?
>
> Thanks
> Magnus
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to