roojs-ui.js
[roojs1] / roojs-ui-debug.js
index c7f1e2d..d10424f 100644 (file)
@@ -20501,7 +20501,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;
         }
@@ -20514,13 +20513,14 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
         }
         
         var rec = view.store.getAt(ix[0]);
-        if (!this.isLoading) {
-            this.setFromData(rec.data);
-        }
+         
+        this.setFromData(rec.data);
         
         
         var lw = Math.floor(
-                ((this.listWidth * this.maxColumns || Math.max(this.wrap.getWidth(), this.minListWidth)) - this.list.getFrameWidth('lr')) / this.maxColumns
+             (
+               (this.listWidth * this.maxColumns || Math.max(this.wrap.getWidth(), this.minListWidth)) - this.list.getFrameWidth('lr')
+           ) / this.maxColumns
         );
         
         this.stores[opts.list+1].loadDataFromChildren( rec );
@@ -20531,11 +20531,14 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
         this.list.setWidth(lw * (opts.list + (dl ? 2 : 1)));
         
         if (this.isLoading) {
-            this.selectActive(opts.list);
+           // this.selectActive(opts.list);
         }
-        
-        
+         
     },
+    
+    
+    
+    
     onDoubleClick : function()
     {
         this.collapse(); //??
@@ -20543,13 +20546,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
@@ -20558,70 +20558,53 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, {
         });
         var _this = this;
         var record  = false;
+       var srec = false;
         if(store.getCount() < 1){
             return false;
         }
         store.each(function(r){
             if(r.data[prop] == value){
                 record = r;
+               srec = r;
                 return false;
             }
             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;
-        }
-        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) {
-                    record = r;
-                    return false;
-                }
-            }
-             
-            return true;
-        });
-        if (record !== false) {
-            var ix = store.getIndexOf(record);
-            this.views[lvl].function(ix, false, true); // will not trigger select change..
-        }
-        
+       // if store is not loaded, then we will need to wait for that to happen first.
+        var stack = [];
+       this.findRecordInStore(this.store, this.hiddenName, this.getValue(), stack);
+       for (var i = 0; i < stack.length; i++ ) {
+           this.view[i].select(stack[i].store.indexOf(stack[i]), false, false );
+       }
+       
     }
+       
+