Announcement

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

    Exporting inherited fields from ListGrid

    SmartGWT 2.5
    Firefox 12.0

    Hi - I seem to be having an issue with exporting inherited datasource fields from a Grid. The grid displays all my info fine (some columns are hidden by default), but when I export, it only exports the fields that are defined in the lowest-level datasource.ds.xml file. In this example I have retailerProductDataSource inheriting from baseRecordDataSource. I want fields from both datasources included in the export. Currently I only get data for the retailerProductDataSource fields.

    In the request, it doesn't appear to set the extra fields in the exportFields from the client-point-of-view, making me think I need to implement a custom export in the DataSource, but I thought I'd check to see if this is actually necessary or not:
    Code:
    [java] === 2012-07-11 11:55:34,709 [l0-3] DEBUG RPCManager - Request #1 (DSRequest) payload: {
         [java]     criteria:{
         [java]         showResults:"All",
         [java]         showFilteringSelection:"showAll",
         [java]         titleInput:"ABCD",
         [java]         searchBy:"RETAILER"
         [java]     },
         [java]     operationConfig:{
         [java]         dataSource:"retailerProductDataSource",
         [java]         operationType:"fetch",
         [java]         textMatchStyle:"exact"
         [java]     },
         [java]     exportResults:true,
         [java]     exportAs:"csv",
         [java]     exportDelimiter:",",
         [java]     exportTitleSeparatorChar:"",
         [java]     exportFilename:"results.csv",
         [java]     exportDisplay:"download",
         [java]     lineBreakStyle:"default",
         [java]     exportFields:[
         [java]         "source",
         [java]         "fileID",
         [java]         "lastUpdatedFileID",
         [java]         "status",
         [java]         "createdDate",
         [java]         "updatedDate"
         [java]     ],
         [java]     exportFieldTitles:{
         [java]         source:"Record Source",
         [java]         productCode:"Product Code",
         [java]         title:"Title",
         [java]         author:"Author",
         [java]         fileID:"Created File ID",
         [java]         lastUpdatedFileID:"Last Updated File ID",
         [java]         status:"Record Status",
         [java]         createdDate:"Created Date",
         [java]         updatedDate:"Updated Date"
         [java]     },
         [java]     appID:"builtinApplication",
         [java]     operation:"retailerProductDataSource_fetch",
         [java]     oldValues:{
         [java]         showResults:"All",
         [java]         showFilteringSelection:"showAll",
         [java]         titleInput:"ABCD",
         [java]         searchBy:"RETAILER"
         [java]     }
         [java] }
    Do I have to implement a custom export (as shown in the Showcase), or am I doing something daft and should it happen by default?

    (Removed some company-sensitive values).
    Code:
    <DataSource  ID="retailerProductDataSource" serverConstructor="com.mypackage.datasource.RetailerProductDataSource"            mappedBeanClass="com.mypackage.entity.ConvertedRecord"
         inheritsFrom="baseRecordDataSource"      
     >    
        <fields>
           <field name="fileID" type="integer" />
           <field name="status" type="enum" >
               <valueMap>
                   <value name="NOT_PROCESSED" />
                   <value name="QUEUED_FOR_CONVERSION" />
                   <value name="CONVERSION_IN_PROGRESS" />
                   <value name="CONVERTED" />
                   <value name="CONVERSION_ERROR" /> 
               </valueMap>
           </field>
           <field name="source" type="enum" >
               <valueMap>
                   <value name="VAL_1" />
                   <value name="VAL_2" />
                   <value name="VAL_3" />
                   <value name="VAL_4" />
                   <value name="VAL_5" /> 
               </valueMap>
           </field>
           <field name="createdDate" type="datetime" />
           <field name="updatedDate" type="datetime" />
           <field name="lastUpdatedFileID" type="integer" />
        </fields>  
    </DataSource>
    Code:
    <DataSource  
         ID="baseRecordDataSource" serverConstructor="com.mypackage.datasource.BaseRecordDataSource"       
         mappedBeanClass="com.mypackage.entity.BaseRecord"
    >   
           <field name="productCode" type="text" />       
           <field name="title" type="text" />
           <field name="productClass" type="text" />
    </DataSource>
    Client code
    Code:
    DSRequest dsRequestProperties = new DSRequest();  
    dsRequestProperties.setExportAs(ExportFormat.CSV);  
    dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);  
    dsRequestProperties.setExportFilename("results.csv");
    ...
    grid.exportData(dsRequestProperties);
    I've tried explicitly setting the column names on both the client and in the datasource using dsRequestProperties.setExportFields(); with mixed results in that it creates a CSV file with the right headers but doesn't output any rows unless I include fields that are in the retailerProductDataSource.ds.xml file!

    Thanks,
    FB.

    #2
    Ok, this appears to be nothing to do with inhertsFrom and everything to do with hidden fields in my grid. Apologies if I've wasted anyone's time.

    Currently mocking up potential solutions based on answers to other threads in this group (search "export hidden field").

    FB.

    Comment

    Working...
    X