Saturday, December 20, 2014

Tricky DataGrid Live Update Question

Working on a stock market system, I've implemented a data grid that shows the open positions for a trader. That grid has a number of columns showing current price fluctuations which might change as many as 20 times a second. There is also a column containing a "close position" button pressing which causes the position to be closed. The smallest resolution GWT provides for grid update is redrawRow(int row). That's what I use to update the grid with live data.

The problem I have is that redrawRow() sometimes cancels close button events. To put it more precisely, if a user presses and holds the close button pressed for a while, and then releases it, the event will be lost if redrawRow has been invoked for the same row. That is reported as "very annoying" by most users, and we are failing to come up with a workaround to solve it. Do you have any idea how to solve this issue?

Below is how we create the close button cell:

private static ButtonCell closeButton = new ButtonCell(){
       
       
private String imageResource = new Image(FxResources.INSTANCE.closePosition().getSafeUri()).toString();
       
       
private SafeHtml html = SafeHtmlUtils.fromTrustedString(
               
"<button type=\"button\" class=\"gwt-Button\">" + imageResource + "</button>");
               
       
@Override
       
public void render(
               
final Context context,
               
final SafeHtml data,
               
final SafeHtmlBuilder sb) {
            sb
.append(html);
       
}
   
};

Adding the button cell to a column and wiring it up:

final Column<MarketOrderDTO, String> closeColumn = new Column<MarketOrderDTO, String>(closeButton) {
           
           
@Override
           
public String getValue(MarketOrderDTO mo) {
               
return "";
           
}
       
};
        closeColumn
.setCellStyleNames("closeButtonCell");
        closeColumn
.setFieldUpdater(new FieldUpdater<MarketOrderDTO, String>() {

           
@Override
           
public void update(int index, MarketOrderDTO mo, String value) {
               
OrderProcessor.closeMarketOrder(mo);
           
}
       
});
        dataGrid
.addColumn(closeColumn, "");



Thanks!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment