+ * @private
+ * Returns a filter function used to test a the given property's value. Defers most of the work to
+ * Ext.util.MixedCollection's createValueMatcher function
+ * @param {String} property The property to create the filter function for
+ * @param {String/RegExp} value The string/regex to compare the property value to
+ * @param {Boolean} anyMatch True if we don't care if the filter value is not the full value (defaults to false)
+ * @param {Boolean} caseSensitive True to create a case-sensitive regex (defaults to false)
+ * @param {Boolean} exactMatch True to force exact match (^ and $ characters added to the regex). Defaults to false. Ignored if anyMatch is true.
+ */
+ createFilterFn : function(property, value, anyMatch, caseSensitive, exactMatch){
+ if(Ext.isEmpty(value, false)){
+ return false;
+ }
+ value = this.data.createValueMatcher(value, anyMatch, caseSensitive, exactMatch);
+ return function(r) {
+ return value.test(r.data[property]);
+ };
+ },
+
+ /**
+ * @private
+ * Given an array of filter functions (each with optional scope), constructs and returns a single function that returns
+ * the result of all of the filters ANDed together
+ * @param {Array} filters The array of filter objects (each object should contain an 'fn' and optional scope)
+ * @return {Function} The multiple filter function
+ */
+ createMultipleFilterFn: function(filters) {
+ return function(record) {
+ var isMatch = true;
+
+ for (var i=0, j = filters.length; i < j; i++) {
+ var filter = filters[i],
+ fn = filter.fn,
+ scope = filter.scope;
+
+ isMatch = isMatch && fn.call(scope, record);
+ }
+
+ return isMatch;
+ };
+ },
+
+ /**
+ * Filter the {@link Ext.data.Record records} by a specified property. Alternatively, pass an array of filter
+ * options to filter by more than one property.
+ * Single filter example:
+ * store.filter('name', 'Ed', true, true); //finds all records containing the substring 'Ed'
+ * Multiple filter example:
+ * <pre><code>
+ * store.filter([
+ * {
+ * property : 'name',
+ * value : 'Ed',
+ * anyMatch : true, //optional, defaults to true
+ * caseSensitive: true //optional, defaults to true
+ * },
+ *
+ * //filter functions can also be passed
+ * {
+ * fn : function(record) {
+ * return record.get('age') == 24
+ * },
+ * scope: this
+ * }
+ * ]);
+ * </code></pre>
+ * @param {String|Array} field A field on your records, or an array containing multiple filter options