Grid with many columns.
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.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, jqxlistbox.js, jqxdropdownlist.js, jqxgrid.filter.js, jqxgrid.edit.js, jqxgrid.selection.js, jqxgrid.columnsresize.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 () {
// prepare the data
var data = new Array();
var columns = new Array();
var datafields = new Array();
for (var i = 0; i < 200; i++) {
var row = {};
for (var j = 0; j < 200; j++) {
row["Name" + j] = "Cell " + (1+i) + "." + (1+j);
if (i == 0) {
columns.push({ datafield: "Name" + j, text: "Column " + (1+j), width: 100 });
datafields.push({ name: "Name" + j, type: "string" });
}
}
data[i] = row;
}
var source =
{
localdata: data,
datatype: "array",
datafields: datafields
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#grid").jqxGrid(
{
width: getWidth('Grid'),
source: dataAdapter,
columns: columns
});
});
<div id="grid">
</div>