Author Topic: exportData and Hidden Columns  (Read 3790 times)

BuckWheat

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 3
  • BuckWheat
    • View Profile
exportData and Hidden Columns
« on: July 12, 2017, 12:55:53 am »
Hi there,

I am attempting to export data from the grid. I need to do a pile of queries and what not before the export, since they client wants the view on the screen and the export to be dramatically different. We want the same records, just way more columns, and child records, and, and, and.... So I added a url to the exportData function and I have it posting to the server. I need the data from the grid to know which rows of data to include in the new export. To this end I have added a hidden column to the grid and it contains the ID I need for the server side processing.

My Id is never sent in the export to the server. The mark up looks like:
              {
                  title: "MyId", width: 50, dataType: "integer", dataIndx: "MyId",
                  hidden: true, exportRender: true, copy: true
              },
I have set all of my other columns to be "exportRender: false, copy: false" and they are not included (as expected in the export). The server side method is currently getting a blank spreadsheet. I have tried setting the "render" argument of the exportData to true and false but it doesn't seem to have an impact on this. How do I get a hidden column to be included in the export?

The pq_data argument contains a spreadsheet or a CSV or an HTML file.... I want a format that is easy to chew on server side so that I can build out my new export, so I set it to CSV, but as soon as I set the format, then that is what the client writes the file as - no matter what I set the return content type and filename to. I want CSV sent to the server and XLSX sent to the client. The exportData function doesn't seem to allow different data formats to be sent than received. Is there away around this?

Thanks

-Cam

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: exportData and Hidden Columns
« Reply #1 on: July 12, 2017, 04:18:55 pm »
In case of xlsx export, hidden columns are included in the export, but they remain hidden in the worksheet too. If you are parsing xlsx file on the server with some library, there might be a way to read hidden columns.

Anyway if you want to show them in the worksheet, remove hidden: true in beforeExport event and add hidden: true back in export event.

Hope it helps.

BuckWheat

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 3
  • BuckWheat
    • View Profile
Re: exportData and Hidden Columns
« Reply #2 on: July 12, 2017, 08:13:20 pm »
Thanks.... I will try toggling that flag.
I have been trying to read the Excel file with ClosedXML but it can't read the file at all. I will have to try another library.

Is there a way to send a different format sent to the server than what is sent back to the client?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: exportData and Hidden Columns
« Reply #3 on: July 12, 2017, 09:13:58 pm »
Quote
Is there a way to send a different format sent to the server than what is sent back to the client?

Local export could be used for that.  https://paramquery.com/pro/demos/export_local

First get a csv string from exportData() method, post it to the server -> make changes on the server and turn it into xlsx format -> receive it on client -> use local export.