Announcement

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

  • Client-side export with custom formatting

    Hello, Isomorphic. We stumbled upon a problem when trying to do some custom formatting in client side export.


    We are using client side formatted export, I checked the showcase example “com.smartgwt.sample.showcase.client.dataintegration.java.others.FormattedExportSample”.

    But our case is little bit different - we are using DataSource.fetchData() and manually set this data to listGrid.setData() in success callback. The DataSource.fetchData() is invoked onClick event of the button “LoadData” button that I have added to the sample and fetch Data based on some criteria.
    The problems that we face are:

    1. The cell formatters are not being invoked for export. I am using a CellFormatter for unitPriceField , it works for grid, but not for export :
    ListGridField unitPriceField = new ListGridField("unitPrice");
    unitPriceField.setAlign(Alignment.RIGHT);
    unitPriceField.setWidth(64);
    unitPriceField.setAlign(Alignment.RIGHT);
    unitPriceField.setCellAlign(Alignment.RIGHT);
    unitPriceField.setExportRawValues(false);
    final NumberFormat numFormatter = NumberFormat.getFormat("###,###,###.000");
    unitPriceField.setCellFormatter(new CellFormatter() {
    public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
    double price=record.getAttributeAsDouble("unitPrice");
    return numFormatter.format(price/10);
    }
    });
    What we want to show in export the “value”, where value = someCustomizedFormatter(fieldValue/10) ; so is there any other way that we can customize formatting the data for export?
    I also checked the “setExportFormat()” method, but it is using a fixed format string, it can’t be used for complex calculations.

    2. The other problem is with ListGridField, which is not being shown in the grid but has to be shown in the export. If these field is shown in grid, only then it is being displayed in export, otherwise not.
    The idea is we want to show some different fields in export other than showing in grid.
    In sample code I made the orderDateField.setHidden(true);
    And tried to use setExportFields() in sample code
    dsRequestProperties.setExportFields(new String[]{"orderID", "itemID", "unitPrice", "orderDate", "itemTotalField"}); but in export it is showing only "orderID", "itemID", "unitPrice", "itemTotalField"

    You can find the changed showcase sample in attachments.
    Thanks in advance for your support.

    Best regards,
    Sonia

    Attached Files
Working...
X