Roo/form/ComboNested.js
[roojs1] / Roo / form / ComboNested.js
index 13ecced..dc266a1 100644 (file)
@@ -323,11 +323,12 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
     
     findRecord : function (prop,value)
     {
-        return this.findRecordInStore(this.store, 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
@@ -346,7 +347,7 @@ 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;
                     return false;
@@ -355,11 +356,18 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
              
             return true;
         });
-        
+        if (record == false) {
+           return false
+       }
+       stack.unshift(store, record);
         return record;
     },
     
-    
+    /*
+     * find the stack of stores that match our value.
+     *
+     * 
+     */
     
     selectActive : function (lvl)
     {
@@ -369,26 +377,32 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
             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;
         }
-        var record = false;
+        var value = this.getValue();
+        var prop = this.hiddenName;
+        
+        var _this = this;
         store.each(function(r){
             // selected is at this level
             if(r.data[prop] == value){
-                record = r;
+                var ix = store.getIndexOf(r);
+                _this.views[lvl].select(ix, false, true); // do not trigger set active..
+                _this.loading 
                 return false;
             }
             
             if (r.data.cn && r.data.cn.length) {
-                cstore.loadDataFromChildren( r);
+                cstore.loadDataFromChildren(r);
                 var cret = _this.findRecordInStore(cstore, prop, value);
                 if (cret !== false) {
                     var ix = store.getIndexOf(r);
-                    this.views[lvl].select(ix, false, false); // will trigger select change..
+                    _this.views[lvl].select(ix, false, false); // will trigger select change..
                     return false;
                 }
             }