Announcement

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

    How to export list grid to CSV the information that is displayed?

    PROBLEM: When the ListGrid field column has a foreign key, the export to file also exports the original field and the display field. How do I only export the display field and not the original field?

    INFORMATION:
    1. v10.1p_2016-02-24/Enterprise Deployment
    2. All browsers.
    3. No errors...this maybe a feature request.


    #2
    Are you having trouble using the exportFields property (settable on the UI component, DSRequest or operationBinding) or did you just not check the docs?

    Comment


      #3
      I have tried to set exportFields with DSRequest. Suppose the fields are called: fk and fkShowValue. fkShowValue is hidden. When I export fields with just fk, I get both fk and fkShowValue. When I export fields with just fkShowValue, I get fkShowValue TWICE.

      Comment


        #4
        What kind of export are you talking about? If you look at the docs for exportFields, it has different meaning for different types of export.

        Did you try exportFields on whatever component is exporting (assuming you are doing an export from a component - you haven't said).

        Is there a sample where we can see the effect you're getting by just making slight modifications?

        Comment


          #5
          Here's an example of me trying to manipulate exportFields and the type of export I'm attempting.

          First version
          DSRequest dsRequestProperties = new DSRequest();
          dsRequestProperties.setExportFilename(tableName + ".cvs");
          dsRequestProperties.setExportAs((ExportFormat) EnumUtil.getEnum(ExportFormat.values(), "cvs"));
          dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
          dsRequestProperties.setExportValueFields(true);
          dsRequestProperties.setExportRawValues(false);
          table.exportData(dsRequestProperties);

          Subsequent attempt:
          DSRequest dsRequestProperties = new DSRequest();
          dsRequestProperties.setExportFilename(tableName + ".cvs");
          dsRequestProperties.setExportAs((ExportFormat) EnumUtil.getEnum(ExportFormat.values(), "cvs"));
          dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
          dsRequestProperties.setExportValueFields(true);
          ArrayList<String> fields = new ArrayList<String>();
          String fd = null;
          for(ListGridField lgf : table.getFields())
          {
          fd = lgf.getDisplayField();
          if(null != fd)
          {
          fields.add(fd);
          } else {
          fd = lgf.getName();
          }
          if(fd.startsWith("$"))
          continue;

          fd = lgf.getName();

          SC.logWarn("DISPLAY: " + fd);
          fields.add(fd);
          }
          dsRequestProperties.setExportFields(fields.toArray(new String[fields.size()]));
          dsRequestProperties.setExportRawValues(false);
          table.exportData(dsRequestProperties);
          Last edited by michaeljseo; 24 Feb 2016, 19:08. Reason: Reformat code section for readability.

          Comment


            #6
            We can't run your code because it's partial, but from just reading it, it seems like would add the original field and the display field, resulting in two identical fields as you describe.

            Comment


              #7
              That was the problem...THANK YOU!

              Comment

              Working...
              X