Retrieving CSV Data

In this guide, we'll walk you through how to assign or retrieve CSV data along with how to configure how to parse the data.

Assigning Data to the Grid

If you want to populate your grid using CSV data, then you just need to either set set the data or src attribute.

If your data is hosted in an endpoint, just set the URL to the src attribute, like so:

  <zg-data src=""></zg-data>


Assign the data to the data attribute via JavaScript.

<zing-grid id="myZingGrid"></zing-grid>

  let zgRef = document.querySelector('#myZingGrid'); = `CSV Demo`
    + `First,Last,Number`
    + `Maria,John,123`
    + `David,Smith,456`
    + `Felicity,Snow,789`;


Once the CSV data is added, you can add the following <zg-param>s to configure how to parse the data:

csvCaptionSpecify if the first line should be the caption.
csvDelimiterSpecify the separator to split the columns.
csvHeaderSpecify if the first line (or second if caption defined) should be the column headers
csvLineSeparatorSpecify the separator to split the rows.


Refer to the following demo for an in depth look at using CSV with ZingGrid. Note that the CSV data is tab-separated, so the grid is configured to parse this data format.

CSV file:

CSV Demo
First	Last	Number
Maria	John	123
David	Smith	456
Felicity	Snow	789
  <zg-data src="">
    <zg-param name="csvCaption" value="true"></zg-param>
    <zg-param name="csvDelimiter" value="	"></zg-param>
    <zg-param name="csvHeader" value="true"></zg-param>
    <zg-param name="responseType" value="text/csv"></zg-param>

[data: CSV]