0

I have a list of ids of rows that should be selected, but not the actual objects that will be selected. For example, I know Users 16 and 25 should be selected, but I don't have an instance representing them. This could be because they're on a different page of data that I haven't loaded yet.

I want to be able to select these users programmatically even though their data is not loaded yet. I'm implementing a function called setSelectedIds() and it's working great - I scan all visible objects, and if their id matches one of the ids in my set, I set it Selected. Likewise, if the user changes a selection through the human interface, I catch the SelectionChangeEvent and determine whether an id should be added or removed to my backing list of ids.

The actual question:

Is there an event that's always fired when data has been loaded via updateRowData()? The only thing missing from my implementation is a way to handle the loading of new data. I need to be notified when new data is loaded, so I can decide whether to select it or not. RangeChangeEvents happen to soon - those handlers are fired before the data is loaded, and selectionModel.getSelected() returns some null objects. RowCountChangeEvents only happen when the total number of rows changes. What am I missing?

Riley Lark
  • 20,660
  • 15
  • 80
  • 128

1 Answers1

1

Can't you implement your own SelectionModel? When it's asked whether an object isSelected, it compares its ID with your list of selected IDs. You could even generalize it by using the object's key (given by the ProvidesKey) rather than an hard-coded getId.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • Yes, that's a much better idea. Thanks! For future readers: I actually ended up subclassing CellTable to provide the events I mentioned above, and it's working rather well, but the SelectionModel is a more logical place achieve the behavior I need. Next time! – Riley Lark Apr 19 '11 at 12:21