Filter through all records in the 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.
showfilterbar property – Shows or hides the grid's filter bar.filterbarmode propertywidth property – Sets or gets the Grid's width.columns property – Sets the Grid columns.filterable property – Enables or disables the Grid Filtering feature.sortable property – The sortable property enables or disables the sorting 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, jqxmenu.js, jqxgrid.js, jqxgrid.edit.js, jqxgrid.filter.js, jqxgrid.sort.js, jqxlistbox.js, jqxdropdownlist.js, jqxgrid.selection.js, jqxgrid.aggregates.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).
window.onload = function() {
// prepare the data
var data = generatedata( 200 );
var source =
{
localdata: data,
datatype: "array",
datafields:
[
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'available', type: 'bool' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' }
],
updaterow: function ( rowid, rowdata ) {
// synchronize with the server - send update command
}
};
var dataAdapter = new jqx.dataAdapter( source );
// initialize jqxGrid
var grid = new jqxGrid( "#grid",
{
width: '100%',
source: dataAdapter,
filterable: true,
sortable: true,
showfilterbar: true,
columns: [
{ text: 'First Name', columntype: 'textbox', datafield: 'firstname', width: 170 },
{ text: 'Last Name', datafield: 'lastname', columntype: 'textbox', width: 170 },
{
text: 'Product', datafield: 'productname', width: 170,
},
{
text: 'In Stock', datafield: 'available', columntype: 'checkbox', width: 125,
},
{
text: 'Quantity', datafield: 'quantity', width: 85, cellsalign: 'right', cellsformat: 'n2',
},
{
text: 'Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2'
} ]
} );
var grid2 = new jqxGrid( "#grid2",
{
width: '100%',
source: dataAdapter,
filterable: true,
sortable: true,
filterbarmode: 'simple',
showfilterbar: true,
columns: [
{ text: 'First Name', columntype: 'textbox', datafield: 'firstname', width: 170 },
{ text: 'Last Name', datafield: 'lastname', columntype: 'textbox', width: 170 },
{
text: 'Product', datafield: 'productname', width: 170,
},
{
text: 'In Stock', datafield: 'available', columntype: 'checkbox', width: 125,
},
{
text: 'Quantity', datafield: 'quantity', width: 85, cellsalign: 'right', cellsformat: 'n2',
},
{
text: 'Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2'
} ]
} );
};
<h3>Grid with Search Input and Filter By List</h3>
<div id="grid"></div>
<br>
<h3>Grid with Search Input</h3>
<div id="grid2"></div>