private void initExportButton() {
    setHeight(30);
    exportButton.setShowRollOver(false);
    exportButton.setIcon(GWT.getHostPageBaseURL() + "images/icons/32/woofunction/export_32.png");
    exportButton.setIconOrientation("right");

    final DynamicForm exportForm = new DynamicForm();
    exportForm.setNumCols(4);
    // exportForm.setWidth(300);

    SelectItem exportTypeItem = new SelectItem("exportType", "Exporteer als");
    //    exportTypeItem.setWidth(150);
    exportTypeItem.setDefaultToFirstOption(true);
    LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
    valueMap.put("ooxml", "XLSX (Excel2007+/OOXML)");
    valueMap.put("xls", "XLS (Excel97)");
    valueMap.put("csv", "CSV (Excel)");
    // valueMap.put("xml", "XML");
    // valueMap.put("json", "JSON");
    exportTypeItem.setValueMap(valueMap);

    BooleanItem showInWindowItem = new BooleanItem();
    showInWindowItem.setName("showInWindow");
    showInWindowItem.setTitle("Toon Export in nieuw venster");
    showInWindowItem.setAlign(Alignment.LEFT);

    exportForm.setFields(exportTypeItem, showInWindowItem);

    exportButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            String exportAs = (String) exportForm.getField("exportType").getValue();
            FormItem item = exportForm.getField("showInWindow");
            boolean showInWindow = item.getValue() == null ? false : (Boolean) item.getValue();
            DSRequest dsRequestProperties = new DSRequest();

            // set all fields, also from joined models. If they don't appear in the DS.xml file,
            // they will be ignored. Adding foreign fields to ds.xml automatically makes them being
            // exported as well.
            // (just make sure the query does some joins correctly, as is normal!)
            String[] f = fields == null ? ds.getFieldNames() : fields;

            if (hideInvisibleFieldsFromExport) {
              f = ListGridUtil.getVisibleFields(grid);
            }

            dsRequestProperties.setExportFields(f);

            if (fetchOperation != null) {
              dsRequestProperties.setOperationId(fetchOperation);
            }

            if (criteria != null) {
              dsRequestProperties.setCriteria(criteria);
              dsRequestProperties.setTextMatchStyle(TextMatchStyle.EXACT);
            }

            if (exportAs.equals("json")) {
              // JSON exports are server-side only, so use the OperationBinding on the DataSource
              dsRequestProperties.setOperationId("customJSONExport");
              dsRequestProperties.setExportDisplay(
                  showInWindow ? ExportDisplay.WINDOW : ExportDisplay.DOWNLOAD);

              grid.exportData(dsRequestProperties);
            } else {
              // exportAs is either XML or CSV, which we can do with requestProperties
              dsRequestProperties.setExportAs(
                  (ExportFormat) EnumUtil.getEnum(ExportFormat.values(), exportAs));
              dsRequestProperties.setExportDisplay(
                  showInWindow ? ExportDisplay.WINDOW : ExportDisplay.DOWNLOAD);

              grid.exportData(dsRequestProperties);
            }
          }
        });
    addMember(exportButton);
    addMember(exportForm);
  }