Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid/ListGridField.setCellFormatter(null)

    I wanted to be able to set a cellFormatter and then remove it, enabling the default formatting again. setCellFormatter does not let you do this and blows up when you pass it a null. This is the current code:

    Code:
      public native void setCellFormatter(CellFormatter formatter) /*-{
                var self = this.@com.smartgwt.client.core.DataClass::getJsObj()();
                self.formatCellValue = $debox($entry(function(value, record, rowNum, colNum) {
                    var recordJ = @com.smartgwt.client.widgets.grid.ListGridRecord::getOrCreateRef(Lcom/google/gwt/core/client/JavaScriptObject;)(record);
                    var valueJ = $wnd.SmartGWT.convertToJavaType(value);
                    return formatter.@com.smartgwt.client.widgets.grid.CellFormatter::format(Ljava/lang/Object;Lcom/smartgwt/client/widgets/grid/ListGridRecord;II)(valueJ, recordJ, rowNum, colNum);
                }));
        }-*/;
    I think this could easily be fixed with

    Code:
      public native void setCellFormatter(CellFormatter formatter) /*-{
                var self = this.@com.smartgwt.client.core.DataClass::getJsObj()();[b]
                if (formatter==null)
                  self.formatCellValue = null;
                else[/b]        
                self.formatCellValue = $debox($entry(function(value, record, rowNum, colNum) {
                    var recordJ = @com.smartgwt.client.widgets.grid.ListGridRecord::getOrCreateRef(Lcom/google/gwt/core/client/JavaScriptObject;)(record);
                    var valueJ = $wnd.SmartGWT.convertToJavaType(value);
                    return formatter.@com.smartgwt.client.widgets.grid.CellFormatter::format(Ljava/lang/Object;Lcom/smartgwt/client/widgets/grid/ListGridRecord;II)(valueJ, recordJ, rowNum, colNum);
                }));
        }-*/;

    A workaround is to call
    Code:
      ListGridField.setAttribute("formatCellValue",(String)null);
Working...
X