Use custom filter items in the filter row's dropdowns.
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.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.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.selection.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' }
],
datatype: "array"
};
var dataAdapter = new $.jqx.dataAdapter(source);
var items = new Array();
items.push(data[0].name);
items.push(data[1].name);
items.push(data[2].name);
items.push(data[3].name);
items.push(data[4].name);
$("#grid").jqxGrid(
{
width: 600,
source: dataAdapter,
showfilterrow: true,
filterable: true,
columns: [
{ text: 'Name', filtertype: 'list', filteritems: items, datafield: 'name', width: 200 },
{ text: 'Product', filtertype: 'checkedlist', filteritems: ['Black Tea', 'Green Tea', 'Caffe Latte'], datafield: 'productname'}
]
});
});
<div id="grid">
</div>