Fix #6201 - Category select
[roojs1] / Roo / data / Store.js
index c23e861..7cc3272 100644 (file)
@@ -233,6 +233,7 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, {
     remove : function(record){
         var index = this.data.indexOf(record);
         this.data.removeAt(index);
         if(this.pruneModifiedRecords){
             this.modified.remove(record);
         }
@@ -420,6 +421,17 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, {
             this.totalLength = Math.max(t, this.data.length+r.length);
             this.add(r);
         }
+        
+        if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
+                
+            var e = new Roo.data.Record({});
+
+            e.set(this.parent.displayField, this.parent.emptyTitle);
+            e.set(this.parent.valueField, '');
+
+            this.insert(0, e);
+        }
+            
         this.fireEvent("load", this, r, options, o);
         if(options.callback){
             options.callback.call(options.scope || this, r, options, true);
@@ -438,6 +450,16 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, {
         var r = this.reader.readRecords(o);
         this.loadRecords(r, {add: append}, true);
     },
+    
+     /**
+     * using 'cn' the nested child reader read the child array into it's child stores.
+     * @param {Object} rec The record with a 'children array
+     */
+    loadDataFromChildren : function(rec)
+    {
+        this.loadData(this.reader.toLoadData(rec));
+    },
+    
 
     /**
      * Gets the number of cached records.
@@ -552,7 +574,6 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, {
             }
             value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
         }
-        
         return function(r){
             return value.test(r.data[property]);
         };
@@ -584,35 +605,8 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, {
      * @param {Boolean} anyMatch True to match any part not just the beginning
      */
     filter : function(property, value, anyMatch){
-        
-        if(typeof(property) == 'string'){
-            var fn = this.createFilterFn(property, value, anyMatch);
-            return fn ? this.filterBy(fn) : this.clearFilter();
-        }
-        
-        var fn = [];
-        var afn = [];
-        
-        Roo.each(property, function(p){
-            if(anyMatch == true){
-                afn.push(this.createFilterFn(p, value, true));
-            }
-            
-            fn.push(this.createFilterFn(p, value, false));
-        });
-        
-        if(!fn.length && !afn.length){
-            return this.clearFilter();
-        }
-        
-        var filterData = [];
-        
-        Roo.each(fn, function(f){
-            filterData.push(this.queryBy(fn, scope || this));
-        });
-        
-        this.data = this.queryBy(fn, scope || this);
-        
+        var fn = this.createFilterFn(property, value, anyMatch);
+        return fn ? this.filterBy(fn) : this.clearFilter();
     },
 
     /**