Announcement

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

    ListGrid.exportData() - Translation of columns

    Hi Isomorphic,

    please take a look at this one (v12.0p_2019-10-06/PowerEdition Deployment (built 2019-10-06)).
    When I try to export listGrid data using method "exportData()", translation of column-title is not always applied.
    It applies when, for example, I use HeaderSpan for a specific column. Otherwise I get a "technical" name. But that doesn't make sense in my opinion so I think this is a bug.

    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.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Button;
    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.HeaderSpan;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS extends VLayout implements EntryPoint {
        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();
                }
            });
    
            setWidth100();
            setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    new MyWindow().show();
                }
            });
            addMember(recreateBtn);
            new MyWindow().show();
            draw();
        }
    
        private class MyWindow extends Window {
            public MyWindow() {
                setWidth(400);
                setHeight(300);
                setMembersMargin(0);
                setModalMaskOpacity(70);
                setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                setShowMinimizeButton(false);
                setIsModal(true);
                setShowModalMask(true);
                centerInPage();
    
                final ListGrid exportGrid = new ListGrid();
                exportGrid.setDataSource("animals");
    
                ListGridField commonNameLGF = new ListGridField("commonName");
                ListGridField scientificNameLGF = new ListGridField("scientificName");
                ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
                ListGridField statusLGF = new ListGridField("status");
    
                HeaderSpan headerSpan = new HeaderSpan("HeaderSpan", new String[] { "scientificName", "status" });
                exportGrid.setHeaderSpans(headerSpan);
    
                exportGrid.setFields(commonNameLGF, scientificNameLGF, lifeSpanLGF, statusLGF);
                exportGrid.fetchData();
    
                Button exportButton = new Button("Export_data");
                exportButton.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        exportGrid.exportData();
                    }
                });
    
                addMember(exportGrid);
                addMember(exportButton);
            }
        }
    }
    animals.ds.xml
    Code:
    <DataSource
        ID="animals"
        serverType="sql"
        tableName="animals"
        testFileName="animals.data.xml"
    >
        <fields>
            <field name="commonName"      title="Animal-TRANSLATION"             type="text"/>
            <field name="scientificName"  title="Scientific Name-TRANSLATION"    type="text"  primaryKey="true"  required="true"/>
            <field name="lifeSpan"        title="Life Span-TRANSLATION"          type="integer"/>
            <field name="status"          title="Endangered Status-TRANSLATION"  type="text">
                <valueMap>
                    <value>Threatened</value>
                    <value>Endangered</value>
                    <value>Not Endangered</value>
                    <value>Not currently listed</value>
                    <value>May become threatened</value>
                    <value>Protected</value>
                </valueMap>
            </field>
            <field name="diet"            title="Diet"               type="text"/>
            <field name="information"     title="Interesting Facts"  type="text"  length="1000"/>
            <field name="picture"         title="Picture"            type="image" detail="true"
                   imageURLPrefix="/isomorphic/system/reference/inlineExamples/tiles/images/"/>
        </fields>
    </DataSource>
    Result:

    Click image for larger version  Name:	exportData bug.PNG Views:	0 Size:	5.8 KB ID:	259585

    The translation only applies to the 2nd and 3rd column because of
    Code:
    HeaderSpan headerSpan = new HeaderSpan("HeaderSpan", new String[] { "scientificName", "status" });

    So far we have used "exportClientData()" but we can no longer use it because some ListGrids could contain over 10k data with many columns - export lasts forever. So it is very important for me to export data very quickly and with translation of all column-titles.

    Best regards
    Pavo
    Last edited by pavo123; 7 Oct 2019, 06:13.

    #2
    Actually, the default for exportData() is to export the (raw) field names rather than titles, so the bug you're actually reporting is that this behavior isn't applied to the header spans, which seem to be appended with the field titles. We've fixed this and it will be available in the nightly builds dated 2019-10-11 and beyond.

    Once you have that build, you should be able to get the behavior you want by setting DSRequest.exportPropertyIdentifier: "title" in the request properties passed to exportData().

    Comment


      #3
      Hi Isomorphic,

      then we were lucky with this bug report, you got and fix the bug and I got the way how to translate the column-titles!

      Best regards
      Pavo

      Comment

      Working...
      X