Sourcetable Integration

Export JqGrid to CSV

Jump to


    Welcome to the comprehensive guide on exporting jqGrid data to CSV format, a method that enhances data portability and accessibility, enabling offline access and easy sharing amongst users. CSV files are universally compatible with spreadsheet programs and preserve data in a structured table format without retaining styling or formulas, ensuring a lightweight and plugin-free data transfer. On this landing page, we will delve into what jqGrid is, the step-by-step process of exporting jqGrid to a CSV file using JSONToCSVConvertor, the practical use cases for this export functionality, an innovative alternative to CSV exports for jqGrid using Sourcetable, and a helpful Q&A section to address common inquiries about the exporting process.

    What is jqGrid?

    jqGrid is a JavaScript control that is specifically designed to represent and manipulate tabular data on the web. It is a powerful Ajax-enabled plugin that facilitates the dynamic loading of data through Ajax callbacks, allowing for real-time interaction with the grid data without the need to refresh the entire page.

    As a grid plugin, jqGrid is adept at handling tabular data within web browsers, constructing tables using the colModel, and enabling users to perform operations such as sorting, paging, and searching. It allows for the manipulation of this data, including sending updates, changes, or additions back to the server.

    One of the strengths of jqGrid is its flexibility and ability to be integrated with various server-side technologies. It can work in conjunction with PHP, ASP, Java Servlets, JSP, ColdFusion, and Perl, among others, thereby providing a versatile solution for developers looking to implement data grids in their web applications.

    Exporting jqGrid to a CSV File

    Using JSONToCSVConvertor

    To export the data from a jqGrid using the JSONToCSVConvertor, gather the data from the grid in JSON format (JSONData). Call the JSONToCSVConvertor function with the necessary parameters: JSONData, ReportTitle, ShowLabel, headers, excludeColumns, and fileName. JSONData is the actual data you want to convert. ReportTitle is the desired title of your report. ShowLabel is a boolean value indicating whether to display column labels in the CSV. Headers is an array that should include the names of the columns you wish to appear in the CSV. ExcludeColumns is an array of column names that you want to omit from the CSV. Finally, fileName is the desired name for your output CSV file.

    Using jqGrid CSV Export Functionality

    The jqGrid provides built-in functionality to export data directly to a CSV file without the need for additional plugins or external programs. To use this feature, ensure that your grid's datatype is set to 'local' or that the 'loadonce' parameter is set to true. The export will not work if the datatype is set to 'json' or 'xml'. Also, hidden columns will not be included in the CSV export.

    To perform the export, invoke the method jqGrid('excel', options) on your jqGrid object. The options object can include various properties such as includeLabels, includeGroupHeader, includeFooter, includeHeader, autoPrint, separator, addQuote, and linebreak. If these properties are not specified, the default values are applied. The default behavior includes labels, group headers, footers, and headers, does not auto print the file, uses a comma as the separator, encloses values in quotes, and uses a newline character to separate rows.

    For a more customized CSV export, you can modify the options object to fit your specific requirements before passing it to the jqGrid('excel', options) method.

    Sourcetable Integration

    Streamline Your Data Management with Sourcetable

    Instead of the traditional method of exporting jqGrid to a CSV file and then importing it into another spreadsheet program, consider the dynamic capabilities of Sourcetable to enhance your data management experience. Sourcetable stands out as a powerful tool that syncs your live data from a myriad of apps or databases seamlessly. This integration allows you to bypass the cumbersome steps of manual data export and import, ensuring that you're always working with the most up-to-date information.

    The ease of automatically pulling in data from multiple sources into Sourcetable cannot be overstated. With its ability to facilitate real-time data queries within a user-friendly spreadsheet interface, Sourcetable simplifies complex data analysis. This is particularly beneficial for those seeking to streamline automation and optimize their business intelligence processes. By using Sourcetable, you can maintain the interactive features of jqGrid while leveraging the advanced capabilities of this versatile platform, ultimately saving time and boosting productivity.

    Common Use Cases

    • J
      Sourcetable Integration
      Use case 1: A user can click the export to excel button in the pager of jqGrid to export the current set of data that is displayed after applying a search or filter.
    • J
      Sourcetable Integration
      Use case 2: With the loadonce:true setting enabled, a user can perform a search and then use the export to excel button to export data from the local datasource without the need to pass parameters to the server.
    • J
      Sourcetable Integration
      Use case 3: For exporting data from the local datasource after a search, a user can utilize a custom navigation button to pass the required parameters to a server.
    • J
      Sourcetable Integration
      Use case 4: A user can call the JSONToCSVConvertor method with the necessary arguments to convert JSON data into a CSV file, which can then be downloaded, excluding its use in Internet Explorer.
    • J
      Sourcetable Integration
      Use case 5: The excelExport method can be used by specifying a URL, allowing the user to build and export a CSV from jqGrid data hosted on a server.

    Frequently Asked Questions

    How can I export currently displayed jqGrid data to CSV?

    You can use the custom button inside jqGrid to export the page that is currently rendered in the UI.

    How do I export all jqGrid data, not just the current page?

    To export all data, you need to use the built-in search with all the parameters or the excelExport method from grid.import.js.

    Can I export to CSV without using any plugins?

    Yes, Guriddo jqGrid's exportToCsv method can export to CSV without the need for plugins or external programs.

    How can I exclude specific columns when exporting to CSV?

    With the exportToCsv method, you can configure the export to exclude specific columns. Alternatively, use the JSONToCSVConvertor function and provide an array of column names to exclude in the excludeColumns argument.

    Is it possible to set a custom file name for the exported CSV file?

    Yes, when using the JSONToCSVConvertor function, you can set the fileName argument to your desired CSV file name. The exportToCsv method also allows you to set the fileName option to name your exported file.

    Start working with Live Data

    Analyze data, automate reports and create live dashboards
    for all your business applications, without code. Get unlimited access free for 14 days.