Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This isn't very flexible as it stands but something like this might fit your needs: <strong><a href="http://www.jsfiddle.net/subhaze/mt2cF/" rel="nofollow">Working Example</a></strong></p> <p>filter function for data store</p> <pre><code>// dataStore = JSON object, filter = filter obj function filterStore(dataStore, filter) { return $(dataStore).filter(function(index, item) { for( var i in filter ) { if( ! item[i].toString().match( filter[i] ) ) return null; } return item; }); } </code></pre> <p>usage</p> <pre><code>// result contains array of objects based on the filter object applied var result = filterStore( store, filter); </code></pre> <p>data store as I have it</p> <pre><code>var store = [ {"brand": "Lg", "productname": "Microwave", "price": 200}, {"brand": "Samsung", "productname": "Digi cam", "price": 120}, {"brand": "Sony", "productname": "Lcd TV", "price": 3000}, { "brand": "LG", "productname": "Flat TV", "price": 299}, {"brand": "Samsung", "productname": "Lcd TV", "price": 700}, {"brand": "LG", "productname": "Plasma TV", "price": 3000}, {"brand": "sony", "productname": "Plasma TV", "price": 12929} ]; </code></pre> <p>filter objects I used</p> <pre><code>// RegExp used could most likely be improved, definitely not a strong point of mine :P var filter = { "brand": new RegExp('(.*?)', 'gi'), "productname": new RegExp('(.*?)', 'gi'), "price": new RegExp('299', 'gi') }; var filter2 = { "brand": new RegExp('LG', 'gi'), "productname": new RegExp('(.*?)', 'gi'), "price": new RegExp('(.*?)', 'gi') }; var filter3 = { "brand": new RegExp('Samsung', 'gi'), "productname": new RegExp('(.*?)', 'gi'), "price": new RegExp('(.*?)', 'gi') }; var filter4 = { "brand": new RegExp('(.*?)', 'gi'), "productname": new RegExp('Plasma TV', 'gi'), "price": new RegExp('(.*?)', 'gi') }; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload