[Advanced] Web UI for Building Structured Search or Filter Queries

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

Structured-Filter-Demo

Structured-Filter-Demo2


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.

Related Posts

Cookie-Consent-Using-Bootstrap

How to Create a Simple Cookie Banner Consent Using Bootstrap 4

Cookie Consent Popup Javascript – Quick and simple tutorial for creating a simple Bootstrap cookie banner. If you have a website or blog with people visiting or…

Create-HTML-Terminals

Create Custom HTML Terminals With Pure JavaScript | shell.js

Custom HTML Terminals is A JavaScript library to create HTML terminals on web pages. The shell js JavaScript library offers a straightforward method to create Ubuntu, OS X,…

Bootstrap-Alert-Bootbox

Bootstrap Alert, Confirm, and Flexible Dialog Boxes | Bootbox

Bootbox.js is a small JavaScript library that allows you to create programming dialogs using Bootstrap templates, without having to worry about creating, managing, or removing any required…

Slider-fg-carousel

An Accessible Touch-enabled Slider Web Component | fg-carousel

fg-carousel Slider – A simple & modern slider web component to create versatile, accessible, touch-enabled picture carousels utilizing CSS scroll snap, Custom Element, and Intersection Observer API….

Tags-Input-Component

A Lightweight and Efficient Tags Input Component in Vanilla JS | tagify

tagify transforms an input field or textarea into a tags component, in an easy and customizable way, with great performance and a small code footprint, full of…

copy-to-clipboard-javascript

A Lightweight Library to Copy Text to Clipboard | CopyJS

CopyJS is a lightweight JavaScript library that allows you to copy plain text or HTML content to the clipboard. Must Read: Tiny Library for Copy Text In…