The Structured Filter is a web user interface for creating structured search queries. It is a complete jQuery UI tool, that supports various configurations and themes.
With it, you can create structured search terms where the first name begins with the letter “a”, the birthday begins after 1/1/1990 and the status is (California, New York, FL) … It is a complete jQuery UI tool, supporting various configurations and themes.
How to make use of it:
1. Install and import the Structured Filter plugin into the doc.
# NPM $ npm i structured-filter --save
<!-- jQuery & jQuery UI --> <script src="/path/to/cdn/jquery.min.js"></script> <link href="/path/to/cdn/jquery-ui.min.css" rel="stylesheet" /> <script src="/path/to/cdn/jquery-ui.min.js"></script> <!-- jQuery Structured Filter --> <link href="/path/to/css/structured-filter.css" rel="stylesheet" /> <script src="/path/to/js/structured-filter.js"></script>
2. Prepare your information as follows:
// sample data for Structured-Filter var contacts=[ { type:"text", id:"Lastname", label:"Lastname"}, { type:"text", id:"Firstname", label:"Firstname"}, { type:"boolean", id:"active", label:"Is active"}, { type:"number", id:"age", label:"Age"}, {type:"list", id:"category", label:"Category", list:[ {id:'1', label:"Family"}, {id:'2', label:"Friends"}, {id:'3', label:"Business"}, {id:'4', label:"Acquaintances"}, {id:'5', label:"Other"} ] }, {type:"date", id:"bday", label:"Birthday"}, {type:"text", id:"phone", label:"Phone"}, {type:"text", id:"cell", label:"Mobile"}, {type:"text", id:"Address1", label:"Address"}, {type:"text", id:"City", label:"City"}, {type:"list", id:"State", label:"State", list:[ {id:"AL", label:"Alabama"}, {id:"AK", label:"Alaska"}, {id:"AZ", label:"Arizona"} ] }, {type:"text", id:"Zip", label:"Zip"}, {type:"list", id:"Country", label:"Country", list:[ {label: 'Afghanistan', id: 'AF'}, {label: 'Ă…land Islands', id: 'AX'}, // ... ] } ]
3. Initialize the plugin to generate a filter UI on the web page.
<div id="myFilter"></div>
$('#myFilter').structFilter({ fields: contacts })
4. Add customized filter situations to the filter UI. Each situation should include field
, operator
, and value
properties as follows:
$('#myFilter').structFilter("addCondition", { "field": { "label": "Lastname", "value": "Lastname" }, "operator": { "label": "contains", "value": "ct" }, "value": { "label": "\"N\"", "value": "N" } });
5. All accessible choices to customize the plugin.
$('#myFilter').structFilter({ // data to be filterable fields: [], // date format dateFormat: 'mm/dd/yy', // highlights the last added or modified filter highlight: true, // show/hide button labels buttonLabels: false, // show/hide submit button submitButton: false, // provides hidden fields with the conditions' values to be submitted with the form submitReady: false, // disables operators from conditions disableOperators: false })
6. API strategies.
// remove all filters $('#myFilter').structFilter("clear"); // get the number of filters $('#myFilter').structFilter("length"); // remove a condition (zero indexed) $('#myFilter').structFilter("removeCondition", 0); // get or set the filter $('#myFilter').structFilter("val"); $('#myFilter').structFilter("val", data); $("#myFilter").structFilter("valText"); $("#myFilter").structFilter("valUrl");
7. Event handlers.
$('#myFilter').on("change.search", function(event){ // after conditions are changed }); $('#myFilter').on("submit.search", function(event){ // on submit });
Search Data With Advanced Filter Criteria, Structured Filter Plugin/Github
See Demo And Download
Official Website(evoluteur): Click Here
This superior jQuery/javascript plugin is developed by evoluteur. For extra advanced usage, please go to the official website.