Create a Grid from Tab-delimited text also known as tab-separated values (TSV).
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/homeprices.txt';
// prepare the data
var source =
{
datatype: "tab",
datafields: [
{ name: 'Year', type: 'int' },
{ name: 'HPI', type: 'float' },
{ name: 'BuildCost', type: 'float' },
{ name: 'Population', type: 'float' },
{ name: 'Rate', type: 'float' }
],
url: url
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#grid").jqxGrid(
{
width: getWidth('Grid'),
source: dataAdapter,
columnsresize: true,
columns: [
{ text: 'Year', datafield: 'Year', width: 200},
{ text: 'HPI', datafield: 'HPI', cellsformat: 'f2', width: 200 },
{ text: 'Build Cost', datafield: 'BuildCost', cellsformat: 'f2', width: 180 },
{ text: 'Population', datafield: 'Population', cellsformat: 'f2', width: 100 },
{ text: 'Rate', datafield: 'Rate', cellsformat: 'f5', minwidth: 100 }
]
});
});
<div id="jqxWidget">
<div id="grid"></div>
</div>