This example uses a Content Security Policy meta tag to show that the grid works with CSP

jQuery Grid: Content Security Policy (CSP)

jQWidgets Grid - Content Security Policy demo.

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.

jqxGrid API used in this demo

Source code

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, jqxcheckbox.js, jqxlistbox.js, jqxdropdownlist.js, jqxgrid.js, jqxgrid.sort.js, jqxgrid.pager.js, jqxgrid.selection.js, jqxgrid.edit.js, jqxgrid.filter.js.

It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).

script.js

$(document).ready(function () {
    var url = "../sampledata/products.xml";

    // prepare the data
    var source =
    {
        datatype: "xml",
        datafields: [
            { name: 'ProductName', type: 'string' },
            { name: 'QuantityPerUnit', type: 'int' },
            { name: 'UnitPrice', type: 'float' },
            { name: 'UnitsInStock', type: 'float' },
            { name: 'Discontinued', type: 'bool' }
        ],
        root: "Products",
        record: "Product",
        id: 'ProductID',
        url: url
    };



    var dataAdapter = new $.jqx.dataAdapter(source, {
        downloadComplete: function (data, status, xhr) { },
        loadComplete: function (data) { },
        loadError: function (xhr, status, error) { }
    });

    // initialize jqxGrid
    $("#grid").jqxGrid(
    {
        width: getWidth('Grid'),
        source: dataAdapter,                
        pageable: true,
        autoheight: true,
        sortable: true,
        altrows: true,
        enabletooltips: true,
        editable: true,
filterable: true,
        selectionmode: 'multiplecellsadvanced',
        columns: [
          { text: 'Product Name', columngroup: 'ProductDetails', datafield: 'ProductName', width: 250 },
          { text: 'Quantity per Unit', columngroup: 'ProductDetails', datafield: 'QuantityPerUnit', cellsalign: 'right', align: 'right', width: 200 },
          { text: 'Unit Price', columngroup: 'ProductDetails', datafield: 'UnitPrice', align: 'right', cellsalign: 'right', cellsformat: 'c2', width: 200 },
          { text: 'Units In Stock', datafield: 'UnitsInStock', cellsalign: 'right',  width: 100 },
          { text: 'Discontinued', columntype: 'checkbox', datafield: 'Discontinued' }
        ],
        columngroups: [
            { text: 'Product Details', align: 'center', name: 'ProductDetails' }
        ]
    });
});

body.html

<p>This example uses a Content Security Policy meta tag to show that the grid works with CSP</p>
    <div id="grid">
    </div>

Learn more

More jQuery Grid demos