Grid Export to CSV Options

The export options specific for the CSV format. The csv dictionary can contain the following settings, all being optional:

  • fileName - the name of the file that will be saved.
  • delimiter - the delimiter for the CSV fields. Defaults to comma.
  • dataSource - DataSource options or variable, that can be used to override the current dataSource used by the Grid. If the data source specified here will not be read, one must set the readDataSource variable to true in order for the exporting process to read it.
  • readDataSource - read the custom DataSource, specified with the above option.
  • columnFields - a list of fields determining which fields from the dataSource items to export as columns. If not specified, the current Grid columns will be used.
  • header - the CSV header options.
    • enabled - indicates whether to dislpay a header or not
    • cells - a list of options for the header cells. Cell options include:
      • field - the name of the field in the data source items, to take the value of the column cells from.
      • title - the title of the column to be displayed in the header.
...
exportOptions: {
    csv: {
        fileName: "Data",
        delimiter: ",",
        dataSource: [
            { id: 1, city: "Miami", name: "John" },
            { id: 2, city: "Paris", name: "Mary" },
            { id: 3, city: "London", name: "Brian" },
            { id: 4, city: "New York", name: "Dave" },
        ],
        readDataSource: true,
        header: {
            enabled: true,
            cells: [
                { field: "id", title: "ID", width: 100 },
                { field: "city", title: "City", width: 300 }
            ]
        }
    }
}
...