TreeGrid Exporting services

21 Dec 20177 minutes to read

Description

The following are the types of exporting available in the TreeGrid.

  • PDF Export.
  • Excel Export.

PDF Export

URL

http://js.syncfusion.com/demos/ejServices/api/JSTreeGridExport/PdfExport

Parameter

Type1:

Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF.
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column and template, etc..

Type2:

Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF.
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
fileName String With this parameter you can set the downloaded file name. By default it is set to “Export”.

Type3:

Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF.
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
fileName String With this parameter you can set the downloaded file name. By default it is set to “Export”.
filePath String With this parameter you can set the location where the exporting file should downloaded. It can be local or server machine file path.

Type4:

Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF.
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
exportToFile Boolean Is a Boolean argument, and value ‘true’ specifies the exporting is completed and download it, value ‘false’ specifies the export TreeGrid internally and append something else to it before download starts.
headerText String HeaderText Is to specify the title for export document.
Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF.
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
fileName String With this parameter you can set the downloaded file name. By default it is set to “Export”.
exportToFile Boolean Is a Boolean argument, and value ‘true’ specifies the exporting is completed and download it, value ‘false’ specifies the export TreeGrid internally and append something else to it before download starts.
headerText String HeaderText Is to specify the title for export document.

Type5:

Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF.
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
fileName String With this parameter you can set the downloaded file name. By default it is set to “Export”.
exportToFile Boolean Is a Boolean argument, and value ‘true’ specifies the exporting is completed and download it, value ‘false’ specifies the export TreeGrid internally and append something else to it before download starts.
headerText String HeaderText Is to specify the title for export document.

Type6:

Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF.
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
fileName String With this parameter you can set the downloaded file name. By default it is set to “Export”.
filePath String With this parameter you can set the location where the exporting file should downloaded. It can be local or server machine file path.
exportToFile Boolean Is a Boolean argument, and value ‘true’ specifies the exporting is completed and download it, value ‘false’ specifies the export TreeGrid internally and append something else to it before download starts.
headerText String HeaderText Is to specify the title for export document.

Type7:

Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF.
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
Document Object It specifies in case of multiple exporting, in which document the file export should append, it holds the internally stored PDF files which is exported previously.
exportToFile Boolean Is a Boolean argument, and value ‘true’ specifies the exporting is completed and download it, value ‘false’ specifies the export TreeGrid internally and append something else to it before download starts.
headerText String HeaderText Is to specify the title for export document.

Type8:

Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
Filename string With this parameter you can set the downloaded file name. By default it is set to “Export”.
Document Object It specifies in case of multiple exporting, in which document the file export should append, it holds the internally stored PDF files which is exported previously.
exportToFile Boolean Is a Boolean argument, and value ‘true’ specifies the exporting is completed and download it, value ‘false’ specifies the export TreeGrid internally and append something else to it before download starts.
headerText String HeaderText Is to specify the title for export document.

Type9:

Name Type Description
TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
datasource object It holds the data to be exported in PDF.
TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
Filename string With this parameter you can set the downloaded file name. By default it is set to “Export”.
filePath String With this parameter you can set the location where the exporting file should downloaded. It can be local or server machine file path.
Document Object It specifies in case of multiple exporting, in which document the file export should append, it holds the internally stored PDF files which is exported previously.
exportToFile Boolean Is a Boolean argument, and value ‘true’ specifies the exporting is completed and download it, value ‘false’ specifies the export TreeGrid internally and append something else to it before download starts.
headerText String HeaderText Is to specify the title for export document.

Request

  • JAVASCRIPT
  • <div id="treegrid"></div>
    
    <script>
    
    $("#treegrid").ejTreeGrid({
    
    toolbarClick: function (args) {
    
    this.exportGrid = this["export"];
    
    if (args.itemName == "PDF Export") {                   
        this.exportGrid('http://js.syncfusion.com/ejServices/api/JSTreeGridExport/PdfExport/api/JSTreeGridExport/PdfExport', "", false);
    
    args.cancel = true;
    
    }
    
    }
    
    });
    
    </script>

    Following example will take part in the project service

    public void PdfExport()
    
    {
    
    string gridModel = HttpContext.Current.Request.Params["TreeGridModel"];
    
    TreeGridProperties gridProperty = ConvertGridObject(gridModel);
    
    PdfExport exp = new PdfExport();
    
    TaskDetailsCollection task = new TaskDetailsCollection();
    
    IEnumerable<TaskDetails> result = task.GetDataSource(); // datasource to be exported
    
    TreeGridExportSettings settings = new TreeGridExportSettings();
    
    settings.Theme = ExportTheme.FlatAzure;
    
    exp.Export(gridProperty, result, settings, "Export");
    
    }

    Excel export

    URL

    http://js.syncfusion.com/ejServices/api/JSTreeGridExport/ExcelExport

    Parameter

    Type1:

    Name Type Description
    TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
    datasource object It holds the data to be exported in PDF.
    excelName String It specifies the file extension to be downloaded.
    excelVersion String Excel version in which document should download.
    TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..

    Type2:

    Name Type Description
    TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
    datasource object It holds the data to be exported in PDF.
    excelName String It specifies the file extension to be downloaded.
    excelVersion String Excel version in which document should download.
    TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
    fileName String With this parameter you can set the downloaded file name. By default it is set to “ExcelExport”.

    Type3:

    Name Type Description
    TreeGridProperties Object It takes TreeGrid model properties that should be pass to exporting.
    datasource object It holds the data to be exported in PDF.
    excelName String It specifies the file extension to be downloaded.
    excelVersion String Excel version in which document should download.
    TreeGridExportSettings object Returns the exporting settings like Unicode support, columns fit to width, hidden column, template, etc..
    isLocalSave Boolean It specifies the file have to save locally or can export directly in case of multiple export.
    filePath String With this parameter you can set the location where the exporting file should downloaded. It can be local or server machine file path.

    Request

  • JAVASCRIPT
  • <div id="treegrid"></div>
    
    <script>
    
    $("#treegrid").ejTreeGrid({
    
    toolbarClick: function (args) {
    
    this.exportGrid = this["export"];
    
    if (args.itemName == "Excel Export") {                            
    
    this.exportGrid('http://js.syncfusion.com/ejServices/api/JSTreeGridExport/ExcelExport', "", false);
    
    args.cancel = true;
    
    }
    
    }
    
    });
    
    </script>

    Following example will take part in the project service

    public void ExcelExport()
    
    {
    
    string gridModel = HttpContext.Current.Request.Params["TreeGridModel"];
    
    TreeGridProperties gridProperty = ConvertGridObject(gridModel);
    
    ExcelExport exp = new ExcelExport();
    
    TaskDetailsCollection task = new TaskDetailsCollection();
    
    IEnumerable<TaskDetails> result = task.GetDataSource();
    
    exp.Export(gridProperty, result, "ExcelExport.xlsx", ExcelVersion.Excel2010, new TreeGridExportSettings() { Theme = ExportTheme.FlatAzure });
    
    }