Announcement

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

    exportData and exportClientData

    Hi,

    I have a DS defined as follows:
    Code:
    ...
    		<field name="regionDisplayText" type="text" valueXPath="locCountryregions/name" hidden="true"></field>
        <field name="regionId" type="integer" foreignKey="regionsDS/id" valueXPath="locCountryregions/id" displayField="regionDisplayText"></field>
    
    		<field name="active" type="boolean" >
    			<valueMap>
    				<value ID="true"><fmt:message key="active"/></value>
    				<value ID="false"><fmt:message key="inactive"/></value>
    			</valueMap>
    		</field>
    ...
    I'd like to export all data into excel sheet filtered by the grid's filters.
    Code:
    DSRequest dsRequestProperties = new DSRequest();  
    dsRequestProperties.setExportAs(ExportFormat.XLS);  
    dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
    dsRequestProperties.setExportFilename("users.xls");
    dsRequestProperties.setExportFields(new String[]{regionField.getName(), activeField.getName()});
    dsRequestProperties.setExportValueFields(false);
    userGrid.exportData(dsRequestProperties);
    When I export this file the problem is that valueMap is not applied form the DS definition neither the displayfied from DS definition is applied.

    When I change it to
    Code:
    userGrid.exportClientData(dsRequestProperties);
    then i works fine, but it exports only data currently loaded in the client. Sometimes users can export ten thousand lines so it is generaly not a good idea to load them up first.
    It would slow down the whole system.

    Can you help me with this? What am I supposed to set? It's pointless to show primary keys from related objects in excel.


    2) Is there an override point where I could put my code in order to get the excel object before it is returned to the client?
    I'd like to make some post modification to it.
    a) I'd like to freeze the header row so that when scrolling the header row would be always visible.
    b) I'd like to make the header line bold.

    In a DMI class I can override fetch, update, add,... operations, is there something like export operation?
    thank you for a quick response,
    Zdary

    I use smartGWT 3.0 PRO 7.11.2011

    #2
    To accomplish #1, you can add an operationBinding of type "fetch" which modifies the records to contain the values you want, then supply the operationId of this operationBinding when calling exportData().

    For #2 and #3, you would need to use POI directly and do your own export.

    Comment


      #3
      Hi,

      thank you.
      If I get it right,
      I need to define extra columns containing the display field rather than foreign keys.

      the same for the boolean value active, I need to define activeDisplayText field and fill it in, right?

      it is a shame that *.ds.xml definition of valuemap and display fields cannot be used.

      best regards,
      Zdary

      Comment


        #4
        Not sure what you mean about extra columns. The values you provide to dsResponse.setData() are the values that will get exported.

        Comment


          #5
          I have a JPA data source and I pass JPA(hibernate) entity into the fetch results.

          In the client I define a ListGridColumn for regionID. In the entity class it is type Integer. Users sees a string which is defined in displayField. -> valueXPath="locCountryregions/name"

          I cannot pass into an Integer field "regionId" a String value.

          Code:
          <field name="regionDisplayText" type="text" valueXPath="locCountryregions/name" hidden="true"></field>
          <field name="regionId" type="integer" foreignKey="regionsDS/id" valueXPath="locCountryregions/id" displayField="regionDisplayText"></field>
          so that I need to define a hidden field "regionDisplayText" in the ListGrid and export this field insteadof "regionId".

          Am I correct?

          best regards,
          Zdary

          Comment


            #6
            The QuickStart Guide explains how to use modify DataSources results in a DMI. Call dsResponse.getRecords() - this gives you the data in generic form (List of Maps) which you can then modify without being constrained by your bean definition.

            Comment


              #7
              that was what I wanted.

              Thank you,
              Zdary

              Comment


                #8
                Hi Sir,

                Please provide sample code for export.

                Thanks In Advance,
                Ashok Maddi,
                maddhi.ashok@gmail.com,
                +919014399945.

                Comment


                  #9
                  Originally posted by zdary View Post
                  Hi,

                  I have a DS defined as follows:
                  Code:
                  ...
                  		<field name="regionDisplayText" type="text" valueXPath="locCountryregions/name" hidden="true"></field>
                      <field name="regionId" type="integer" foreignKey="regionsDS/id" valueXPath="locCountryregions/id" displayField="regionDisplayText"></field>
                  
                  		<field name="active" type="boolean" >
                  			<valueMap>
                  				<value ID="true"><fmt:message key="active"/></value>
                  				<value ID="false"><fmt:message key="inactive"/></value>
                  			</valueMap>
                  		</field>
                  ...
                  When I export this file the problem is that valueMap is not applied form the DS definition neither the displayfied from DS definition is applied.
                  To go back the OP's requirements regarding valueMaps, I, too, require my datasource fields' valueMaps to be applied in the exported (CSV/xlsx) data. Seeing as I will have quite a few datasources, I'm keen for a more generic solution than making an operation binding that applies the valueMap specifically for each dataSource.

                  I'd reckon there's a fairly strong argument that a .ds.xml defined valueMap should sensibly be expected to be automatically applied for you.

                  Would you consider implementing this?

                  Comment


                    #10
                    In response to this question, we have improved the documentation around what gets exported for various types of display-mapped field: see the exportFormatting article (this is SmartClient documentation but it applies equally to Smart GWT).

                    So, the clarified docs make clear what you have already discovered - valueMaps are not automatically applied for exports. It is quite likely that we will add the option to do this at some future point, but there is nothing currently planned. If you need this feature in the short term, you may wish to consider sponsoring it; email support@isomorphic.com to ask for a quote.

                    Comment


                      #11
                      Thanks, will be in touch

                      Comment

                      Working...
                      X