Announcement

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

    12.0p ListGrid.exportData() + ds.xml exportFormat results in hard coded format strings displayed in cells

    Hi Isomorphic,

    I have a problem with exportData() + exportFormat (using v12.0p_2020-03-11 and v12.0p_2020-05-03).
    The format String is applied as hard coded text like this in Libre Office (v6.4.2.2), "HH:mm:ss" is a correct FormatString per it's docs.

    The use case here is that we are calculating a date difference and output this a float. Here the number 1 equals 1 day in Excel.
    Pleas note that the format string should also support this format: exportFormat="[HH]:mm:ss", where the [] denote that the hours should not be displayed mod 24 in the Excel cell (see "Time formats" here).


    Click image for larger version

Name:	exportFormatResult.png
Views:	44
Size:	43.5 KB
ID:	262311


    Please see this BuiltInDS based test case (v12.0p_2020-05-03):

    supplyItem.ds.xml:
    Code:
    <field name="unitCost"    type="float"    title="Unit Cost"   required="true" exportFormat="HH:mm:ss">
    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.ExportFormat;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            mainLayout.addMember(recreateBtn);
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle(
                    "FormatString issues in exportData()" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ListGrid supplyItemGrid = new ListGrid(DataSource.get("supplyItem"));
            supplyItemGrid.setAutoFetchData(true);
            supplyItemGrid.setExportFieldWidths(true);
            supplyItemGrid.setExportWidthScale(0.18);
            supplyItemGrid.setCanEdit(true);
            supplyItemGrid.setShowFilterEditor(true);
    
            IButton exportDataBtn = new IButton("exportData()", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    final DSRequest exportRequest = new DSRequest();
                    exportRequest.setExportAs(ExportFormat.OOXML);
                    exportRequest.setExportFilename("myExport");
                    supplyItemGrid.exportData(exportRequest);
                }
            });
    
            VLayout vLayout = new VLayout() {
                {
                    addMembers(supplyItemGrid, exportDataBtn);
                }
            };
            w.addItem(vLayout);
            w.show();
        }
    }
    Best regards
    Blama

    #2
    Sorry, confused here: you have a field of type:"float" but you are setting a format that is meant for a date/time/datetime value. This is definitely not something that the docs say is valid. It looks like you'd like to have a float value interpreted as a duration. Definitely doable via your own code, or via Feature Sponsorship, but not something built in at the moment.

    Comment


      #3
      Hi Isomorphic,

      yes, it's float. Dates in OOXML are floats as well, 0.5 being 12 hours.
      If I output this value and apply my format string "HH:mm:ss" in Libre Office, this is looking as expected ("12:00:00").
      So to me it seems that the format string is just not applied.

      Best regards
      Blama

      Comment


        #4
        OK, let us know if you are interested in Feature Sponsorship to add this kind of functionality as a framework feature. You can easily add a SimpleType that behaves the way you hoped.

        Comment

        Working...
        X