Type what you mean and the grid filters itself, with no filter dialogs or syntax. A built-in parser handles simple queries. For ambiguous or complex phrases, provide your own OpenAI API key: the model interprets the sentence, with fuzzy matching, synonyms and grammar correction, and turns it into grid filters.
The Filter with AI 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.
autoshowfiltericon property – Displays the filter icon only when the column is filtered.selectionmode property – Sets or gets the selection mode.height property – Sets or gets the Grid's height.width property – Sets or gets the Grid's width.columns property – Sets the Grid columns.editable property – The editable property enables or disables the Grid editing feature.filterable property – Enables or disables the Grid Filtering feature.filternlpinput propertysortable property – The sortable property enables or disables the sorting feature.sortmode property – The sortmode property determines the Grid can sort by single or multiple 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, jqxlistbox.js, jqxdropdownlist.js, jqxmenu.js, jqxgrid.js, jqxgrid.filter.js, jqxgrid.sort.js, jqxgrid.edit.js, jqxgrid.selection.js, jqxpanel.js, jqxgrid.columnsresize.js, jqxgrid.columnsreorder.js, jqxgrid.pager.js, jqxsortable.js, jqxgrid.storage.js, jqxkanban.js, jqxcalendar.js, jqxdatetimeinput.js, jqxcheckbox.js.
It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers), generatedata.js (generatedata(), random sample rows).
$(document).ready(function () {
var data = generatedata(500);
var source =
{
localdata: data,
datafields:
[
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'available', type: 'bool' },
{ name: 'productname', type: 'string' },
{ name: 'date', type: 'date' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' }
],
datatype: "array"
};
var adapter = new $.jqx.dataAdapter(source);
$("#grid").jqxGrid(
{
width: '100%',
source: adapter,
filterable: true,
sortable: true,
sortmode: 'many',
editable: true,
filternlpinput: '#filterInput',
autoshowfiltericon: true,
selectionmode: 'multiplecellsadvanced',
columns: [
{ text: 'First Name', datafield: 'firstname', width: 100 },
{ text: 'Last Name', datafield: 'lastname', width: 100 },
{ text: 'Available', columntype: 'checkbox', datafield: 'available', width: 100 },
{ text: 'Product', datafield: 'productname', width: 170 },
{ text: 'Order Date', datafield: 'date', filtertype: 'date', width: 160, cellsformat: 'dd-MMMM-yyyy' },
{ text: 'Quantity', datafield: 'quantity', width: 80, cellsalign: 'right' },
{ text: 'Unit Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2' }
]
});
});
var ICON = {
spark: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l1.7 4.6L18.3 8.3 13.7 10 12 14.6 10.3 10 5.7 8.3 10.3 6.6z"/><path d="M18.5 13.5l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1-2.1-.9 2.1-.9z"/></svg>',
search: '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4-4"/></svg>'
};
document.querySelector('.ai-badge').innerHTML = ICON.spark + ' jqxGrid AI';
document.querySelector('.ai-lead').innerHTML = ICON.search;
// an example query fills the input; 'change' is what the grid's filternlpinput listens to
document.querySelectorAll('.ai-chip').forEach(function (chip) {
chip.addEventListener('click', function () {
var input = document.getElementById('filterInput');
input.value = chip.textContent;
input.dispatchEvent(new Event('change'));
});
});
<div class="ai-wrap">
<div class="ai-hero">
<span class="ai-badge">jqxGrid AI</span>
<h1>Filter in plain language</h1>
<p>Type what you mean and the grid filters itself, with no filter dialogs or syntax. A built-in parser handles simple queries. For ambiguous or complex phrases, provide your own OpenAI API key: the model interprets the sentence, with fuzzy matching, synonyms and grammar correction, and turns it into grid filters.</p>
</div>
<div class="ai-nav">
<a href="filtering-nlp.htm" class="active">Filter</a>
<a href="ai-command-bar.htm">Command bar</a>
<a href="ai-ask-data.htm">Ask your data</a>
<a href="ai-classify-column.htm">Classify</a>
<a href="ai-summarize.htm">Summarize</a>
</div>
<div class="ai-card">
<div class="ai-inputbar">
<span class="ai-lead"></span>
<input type="text" id="filterInput" placeholder="Type a natural language filter">
</div>
<div class="ai-chips">
<span class="ai-chips-label">Try:</span>
<span class="ai-chip">show products where price > 2 and quantity < 5</span>
<span class="ai-chip">filter by product where value = Cappuccino</span>
<span class="ai-chip">show me products with quantity more than 3 and price less than 4</span>
</div>
</div>
<div class="ai-card"><div id="grid"></div></div>
</div>