The Grid filtering feature. Enter some data into the Filter Row.
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.
showfilterrow property – Shows or hides the filter row.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.filterable property – Enables or disables the Grid Filtering feature.source property – Sets and gets the source.clearfilters method – Clears all filters from the Grid.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.selection.js, jqxpanel.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: 'name', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'available', type: 'bool' },
{ name: 'date', type: 'date'},
{ name: 'quantity', type: 'number' }
],
datatype: "array"
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#grid").jqxGrid(
{
width: getWidth('Grid'),
source: dataAdapter,
showfilterrow: true,
filterable: true,
selectionmode: 'multiplecellsextended',
columns: [
{ text: 'Name', columntype: 'textbox', filtertype: 'input', datafield: 'name', width: 215 },
{
text: 'Product', filtertype: 'checkedlist', datafield: 'productname', width: 220
},
{ text: 'Available', datafield: 'available', columntype: 'checkbox', filtertype: 'bool', width: 67 },
{ text: 'Ship Date', datafield: 'date', filtertype: 'range', width: 210, cellsalign: 'right', cellsformat: 'd' },
{ text: 'Qty.', datafield: 'quantity', filtertype: 'number', cellsalign: 'right' }
]
});
$('#clearfilteringbutton').jqxButton({ height: 25});
$('#clearfilteringbutton').click(function () {
$("#grid").jqxGrid('clearfilters');
});
});
<div id="grid">
</div>
<input style="margin-top: 10px;" value="Remove Filter" id="clearfilteringbutton" type="button">