Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
How to export IgGrid to CSV format

Hi Team,

Please let me know how to export the igGrid content into CSV format.

Please update with the sample code to achieve the same.



  • 180
    Offline posted

    Hi Shrenath,

    Thank you for posting in our community.

    I have created and attached a sample illustrating the behavior of downloading the igGrid data to an CSV file.

    On the onClick handler the dataSource and the columns of the grid are retrieved. Also an empty array is created which will contain the parsed data in the correct CSV format.

    var ds = $("#grid").igGrid("option", "dataSource");
    var cols = $("#grid").igGrid("option", "columns");
    var csv = [];

    Then the columns are iterated through to get the key value from each one and  then it is pushed to an empty headerRow array. Afterwards the array is flattened with the joint method and the pushed into the the csv array:

    var headerRow = [];
    $.each(cols, function (index, col) {

    The same is done for the rows with the data:

    $.each(ds, function (index, row) {
    	var csvRow = [];
    	$.each(row, function (index, cell) {

    Finally the populated csv array is passed to a function witch is responsible for converting the array into csv file and start downloading it:

    downloadCSV(csv.join("\n"), "csvExport.csv");

    Let me know if you have any questions.