Roo/form/ComboNested.js
[roojs1] / Roo / form / ComboNested.js
index 04b3171..3d6c3c5 100644 (file)
@@ -281,7 +281,6 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
         var ix = view.getSelectedIndexes();
          
         if (opts.list > this.maxColumns - 2) {
-             
             this.setFromData(ix.length ? view.store.getAt(ix[0]).data : {});
             return;
         }
@@ -313,8 +312,7 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
         if (this.isLoading) {
             this.selectActive(opts.list);
         }
-        
-        
+         
     },
     onDoubleClick : function()
     {
@@ -323,13 +321,10 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
     
      
     
-    findRecord : function (prop,value)
-    {
-        return this.findRecordInStore(this.store, prop,value);
-    },
+    
     
     // private
-    findRecordInStore : function(store, prop, value)
+    recordToStores : function(store, prop, value, stack)
     {
         var cstore = new Roo.data.SimpleStore({
             //fields : this.store.reader.meta.fields, // we need array reader.. for
@@ -338,6 +333,7 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
         });
         var _this = this;
         var record  = false;
+       var srec = false;
         if(store.getCount() < 1){
             return false;
         }
@@ -348,59 +344,38 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
             }
             if (r.data.cn && r.data.cn.length) {
                 cstore.loadDataFromChildren( r);
-                var cret = _this.findRecordInStore(cstore, prop, value);
+                var cret = _this.recordToStores(cstore, prop, value, stack);
                 if (cret !== false) {
                     record = cret;
+                   srec = r;
                     return false;
                 }
             }
              
             return true;
         });
-        
+        if (record == false) {
+           return false
+       }
+       stack.unshift(srec);
         return record;
     },
     
+    /*
+     * find the stack of stores that match our value.
+     *
+     * 
+     */
     
-    
-    selectActive : function (lvl)
+    selectActive : function ()
     {
-        var cstore = new Roo.data.SimpleStore({
-            //fields : this.store.reader.meta.fields, // we need array reader.. for
-            reader : this.store.reader,
-            data : [ ]
-        });
-        // just need to determine which of the current level is selected if any..
-        var value = this.getValue();
-        var prop = this.hiddenName;
-        var store = this.stores[lvl];
-        if(store.getCount() < 1){
-            return false;
-        }
-        var record = false;
-        store.each(function(r){
-            // selected is at this level
-            if(r.data[prop] == value){
-                record = r;
-                return false;
-            }
-            
-            if (r.data.cn && r.data.cn.length) {
-                cstore.loadDataFromChildren( r);
-                var cret = _this.findRecordInStore(cstore, prop, value);
-                if (cret !== false) {
-                    var ix = store.getIndexOf(r);
-                    this.views[lvl].select(ix, false, true); // will not trigger select change..
-                    this.store.loadDataFromChildren(r); // will trigger load.
-                    this.selectActive(lvl+1);
-                    return false;
-                }
-            }
-             
-            return true;
-        });
-         
+        
+       var stack = [];
+       var rec =  this.findRecordInStore(this.store, this.hiddenName, this.getValue());
+       
     }
+       
+