The Column Template demo of the jQuery Grid.
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.
autoheight property – Sets or gets the height of the grid to be equal to the summary height of the grid rows.width property – Sets or gets the Grid's width.columns property – Sets the Grid columns.pageable property – Enables or disables the Grid Paging feature.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, jqxlistbox.js, jqxdropdownlist.js, jqxmenu.js, jqxgrid.js, jqxgrid.pager.js, jqxgrid.selection.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 url = "../sampledata/feed.xml";
var source =
{
datatype: "xml",
datafields: [
{ name: 'title', type: 'string' },
{ name: 'link', type: 'string' },
{ name: 'pubDate', type: 'date' },
{ name: 'creator', map: 'dc\\:creator', type: 'string' },
],
root: "channel",
record: "item",
url: url
};
var linkrenderer = function (row, column, value) {
if (value.indexOf('#') != -1) {
value = value.substring(0, value.indexOf('#'));
}
var format = { target: '"_blank"' };
var html = $.jqx.dataFormat.formatlink(value, format);
return html;
}
var dataAdapter = new $.jqx.dataAdapter(source);
// Create jqxGrid.
$("#grid").jqxGrid(
{
width: getWidth('Grid'),
source: dataAdapter,
pageable: true,
autoheight: true,
columns: [
{ text: 'Link', datafield: 'link', width: 550, cellsrenderer: linkrenderer },
{ text: 'Title', datafield: 'title', width: 200 },
{ text: 'Publish Date', datafield: 'pubDate', width: 250, cellsformat: "D" },
{ text: 'Creator', datafield: 'creator', width: 200 }
]
});
});
<div id="grid">
</div>