Announcement

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

    Difference between exportData and ExportClientData

    SmartClient Version: v11.0p_2017-02-11/PowerEdition Deployment (built 2017-02-11)

    I am using listgrid in my project. I have a huge amount of data to be displayed in grids and i want to export the same. I am using .ds files and RPCManager to setAction URL. Some columns have number formatting on them.
    1. What is the difference between exportData and ExportClientData? Which one should be used.
    2. While using exportData, the field names are shown instead of titles.



    #2
    You can read the documentation to find out what these two methods do, and how to control their output. For future reference, this strategy applies to any SmartGWT method that you might want to know about.

    Comment


      #3
      I realized that since i have a huge data i should be using exportData. I am facing below issues:
      1. The sort order and filter criteria is not being set in the downloaded excel.
      2. There are few columns for which the title is being set dynamically on client side. How to get title in exported excel.
      3. The number format is not being set in exported sheet.

      -. I am using RPCManager action Url as below:
      RPCManager.setActionURL(GWT.getHostPageBaseURL() + "/vendor");

      - .and my code for export is as follows:
      DSRequest dsRequestProperties = new DSRequest();
      dsRequestProperties.setExportAs((ExportFormat)ExportFormat.XLS);
      dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
      dsRequestProperties.setExportPropertyIdentifier(PropertyIdentifier.TITLE);
      listgrid.exportData(dsRequestProperties);

      -. and in controller i have the fetch operation defined as follows:
      @RequestMapping(method = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT })
      public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      RPCManager rpc;
      try {
      rpc = new RPCManager(request, response);
      } catch (Exception e) {
      return null;
      }

      for (Iterator i = rpc.getRequests().iterator(); i.hasNext();) {
      Object req = i.next();
      if (req instanceof RPCRequest)
      throw new Exception("This example expects only DSRequests");
      DSRequest dsRequest = (DSRequest) req;

      String dsName = dsRequest.getDataSourceName();
      if (!"Vendor".equals(dsName)) {
      rpc.send(dsRequest, dsRequest.execute());
      continue;
      }
      DSResponse dsResponse = new DSResponse();
      dsResponse.setSuccess();
      String operation = dsRequest.getOperationType();
      try {
      if (dsName.equals("Vendor")) {
      if (operation.equals(DataSource.OP_FETCH)) {

      List<Vendor> matchingItems = (List<Vendor>) this.vendorManagerImpl.getAllVendors();
      if(dsRequest.getOperationId().equals("export")){
      System.out.println("sort" + dsRequest.getSortByFields());
      if(null!=dsRequest.getSortByFields()){
      dsRequest.setSortBy(dsRequest.getSortByFields());
      }

      dsResponse.setData(matchingItems);
      }
      } else {
      dsResponse.setFailure();
      dsResponse.setData("Unknown operationType: " + operation);
      }
      }
      } catch (DataAccessException e) {
      System.out.println();
      // throw new GwtException(dsRequest, dsResponse,rpc,e);
      }

      rpc.send(dsRequest, dsResponse);

      }
      return null;
      }

      - The payload from client received is as follows:
      [DEBUG] [qtp77269878-31] com.isomorphic.rpc.RPCManager - Request #1 (DSRequest) payload: {
      criteria:{
      },
      operationConfig:{
      dataSource:"Vendor",
      repo:null,
      operationType:"fetch",
      textMatchStyle:"substring"
      },
      exportResults:true,
      exportAs:"xls",
      exportDelimiter:",",
      exportTitleSeparatorChar:"",
      exportFilename:"Results.xls",
      exportPath:null,
      exportDisplay:"download",
      lineBreakStyle:"default",
      exportFields:[
      "abbr",
      "name",
      "web_url"
      ],
      exportHeader:null,
      exportHeaderless:null,
      exportFooter:null,
      exportFieldTitles:{
      abbr:"Abbr.",
      name:"Name",
      web_url:"Web Address",
      details:"Details "
      },
      exportDatesAsFormattedString:null,
      exportRawValues:false,
      exportCurrencySymbol:"$",
      exportHeaderSpans:null,
      exportOtherFields:{
      abbr:"Abbr.",
      name:"Name",
      web_url:"Web Address",
      details:"Details "
      },
      exportWrapHeaderTitles:null,
      exportPropertyIdentifier:"title",
      sortBy:[
      "name"
      ],
      appID:"builtinApplication",
      operation:"export",
      oldValues:null
      }

      Comment


        #4
        Remember to use CODE tags or indenting will be lost and your post is illegible.

        1. Your code ignored the filter and sort sent by the client and just returns an unsorted, unfiltered list

        2 & 3. Keep reading docs as previously suggested

        Comment


          #5
          Thanks for the response.
          How do i set the sort order on server side. I am getting the sortBy fields on server side. But i cannot add the sort order in fetch query because there are few fields for which IDs are fetched from DB and then based on some logic i am extracting the values corresponding to those ids and displaying the same.

          Comment


            #6
            I am facing the same issue with filter values. Can i set the filter criteria map on server side after fetching all the values from DB.

            Comment


              #7
              Again, your code just ignores the filter and sort information in the DSRequest and just calls a method of your own getAllVendors(). Obviously that won't work.

              We don't know anything about the rest of your server-side so we can't tell you how to get a filtered, sorted list from your own code.

              Comment

              Working...
              X