1

I want to add a special selection model to the celltable. Basically the function i want to have is to select a row on the table which is located on left side, a corresponding form will pop up on the right side. I know so many people will use the singleSelectionModel with SelectionChangeHandler. But there is problem with this method.

For example, if I select row 1 on the table. the form pop up. I close the form by clicking the close-button. Later then, I select the row 1 again, the event is not fired, because it is SelectionChangeHandler. I have to select other row before doing this. This is no good.

So I think there are a few ways to do this:

  1. Make the row deselected right after I select the row.
  2. Use click handler to fire the event ( to pop up the form)
  3. Use other selection model with other selection handler to do this. (I have no ideas about this though)

So my questions are,

  1. Does anyone know what kind of other selection handler I can use for this.
  2. If I use the click handler on celltable, will there be any problem?

I just want to learn more about this. So any ideas will be welcome. Thanks a lot.

Best Regards.

Joey
  • 2,732
  • 11
  • 43
  • 63

2 Answers2

1

Use NoSelectionModel. It won't update the table view after the row is selected. That is, even if the same row is selected, the change event is fired.

//Here 'Contact' is the datatype of the record
final NoSelectionModel<Contact> selModel = new NoSelectionModel<Contact>();
selModel.addSelectionChangeHandler(new Handler() {
    @Override
    public void onSelectionChange(SelectionChangeEvent event) {
        Contact clickedObject = selModel.getLastSelectedObject();
        GWT.log("Selected " + clickedObject.name);
    }
});
table.setSelectionModel(selModel);
Ganesh Kumar
  • 3,220
  • 1
  • 19
  • 27
0

I have using cell table in my each project. The better way to just deselect row manually as u mention. and make change css such as selected cell table's row look not changed after selection.

bNd
  • 7,512
  • 7
  • 39
  • 72