Create a Grid from Comma-delimited text also known as comma-separated values (CSV).
A live JavaScript/jQuery example of jqxGrid, the jQWidgets Grid component, with its complete source code below. It is one of 139 jqxGrid demos for jQuery.
width property – Sets or gets the Grid's width.columns property – Sets the Grid columns.columnsresize property – Enables or disables the columns resizing.source property – Sets and gets the source.To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $. Getting started with jqxGrid shows the setup step by step.
The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxdata.js, jqxbuttons.js, jqxscrollbar.js, jqxmenu.js, jqxgrid.js, jqxgrid.selection.js, jqxgrid.columnsresize.js, jqxlistbox.js, jqxdropdownlist.js.
It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).
$(document).ready(function () {
var url = '../sampledata/nasdaq_vs_sp500.txt';
var source =
{
datatype: "csv",
datafields: [
{ name: 'Date', type: 'date' },
{ name: 'S&P 500', type: 'float' },
{ name: 'NASDAQ', type: 'float' }
],
url: url
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#grid").jqxGrid(
{
width: getWidth('Grid'),
source: dataAdapter,
columnsresize: true,
columns: [
{ text: 'Date', datafield: 'Date', cellsformat: 'D', width: 250},
{ text: 'S&P 500', datafield: 'S&P 500', width: 300, cellsformat: 'f' },
{ text: 'NASDAQ', datafield: 'NASDAQ', cellsformat: 'f' }
]
});
});
<div id="jqxWidget">
<div id="grid"></div>
</div>