X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-debug.js;h=c7270b5dd996414100dce134598a3a1f702263c2;hp=7ce62117710d0a39649898ad3877751126f68b58;hb=refs%2Fheads%2Fwip_alan_T6201_Category_select;hpb=9aa337b8a367eb1f56c281e77e068e6ee7e6724b diff --git a/roojs-debug.js b/roojs-debug.js index 7ce6211771..c7270b5dd9 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -23275,7 +23275,7 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { */ loadDataFromChildren : function(rec) { - + this.loadData(this.reader.toLoadData(rec)); }, @@ -24474,15 +24474,12 @@ Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, { totalRecords : totalRecords }; }, - /** - * 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) + // used when loading children.. @see loadDataFromChildren + toLoadData: function(rec) { // expect rec just to be an array.. eg [a,b,c, [...] << cn ] var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn; - return this.loadData({ data : data, total : data.length }); + return { data : data, total : data.length }; } });/* @@ -24707,14 +24704,11 @@ Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, { totalRecords : records.length }; }, - /** - * 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) + // used when loading children.. @see loadDataFromChildren + toLoadData: function(rec) { // expect rec just to be an array.. eg [a,b,c, [...] << cn ] - return this.loadData(typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn); + return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn; } @@ -42768,11 +42762,13 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, { views : null, stores : null, // private + loadingChildren : false, + onRender : function(ct, position) { Roo.form.ComboBox.superclass.onRender.call(this, ct, position); // skip parent call - got to above.. - if(this.hiddenName){ + if(this.hiddenName){ this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName, id: (this.hiddenId||this.hiddenName)}, 'before', true); this.hiddenField.value = @@ -42877,9 +42873,7 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, { }); } this.stores[i] = store; - - - + var view = this.views[i] = new Roo.View( il, this.tpl, @@ -42909,8 +42903,7 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, { }, - onResize : function() {}, - + restrictHeight : function() { var mh = 0; @@ -42918,13 +42911,14 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, { var el = this.views[i].getEl(); el.dom.style.height = ''; var inner = el.dom; - var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight); + var h = Math.max(il.clientHeight, il.offsetHeight, il.scrollHeight); // only adjust heights on other ones.. + mh = Math.max(h, mh); if (i < 1) { el.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight); il.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight); - mh = Math.max(el.getHeight(), mh); + } @@ -42953,7 +42947,19 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, { // private onLoad : function(a,b,c,d) { + if (!this.loadingChildren) { + // then we are loading the top level. - hide the children + for (var i = 1;i < this.views.length; i++) { + this.views[i].getEl().setStyle({ display : 'none' }); + } + var lw = Math.floor( + ((this.listWidth * this.maxColumns || Math.max(this.wrap.getWidth(), this.minListWidth)) - this.list.getFrameWidth('lr')) / this.maxColumns + ); + this.list.setWidth(lw); // default to '1' + + + } if(!this.hasFocus){ return; } @@ -42964,6 +42970,10 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, { } else { this.onEmptyResults(); } + + if (!this.loadingChildren) { + this.selectActive(); + } /* this.stores[1].loadData([]); this.stores[2].loadData([]); @@ -42984,42 +42994,72 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, { } - } , - - + }, + // no cleaning of leading spaces on blur here. + cleanLeadingSpace : function(e) { }, + onSelectChange : function (view, sels, opts ) { var ix = view.getSelectedIndexes(); - - + if (opts.list > this.maxColumns - 2) { - - this.setFromData(ix.length ? view.store.getAt(ix[0]).data : {}); + if (view.store.getCount()< 1) { + this.views[opts.list ].getEl().setStyle({ display : 'none' }); + + } else { + if (ix.length) { + // used to clear ?? but if we are loading unselected + this.setFromData(view.store.getAt(ix[0]).data); + } + + } + return; } if (!ix.length) { - this.setFromData({}); + // this get's fired when trigger opens.. + // this.setFromData({}); var str = this.stores[opts.list+1]; - str.removeAll(); + str.data.clear(); // removeall wihtout the fire events.. return; } var rec = view.store.getAt(ix[0]); + this.setFromData(rec.data); + this.fireEvent('select', this, rec, ix[0]); 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.loadingChildren = true; this.stores[opts.list+1].loadDataFromChildren( rec ); + this.loadingChildren = false; var dl = this.stores[opts.list+1]. getTotalCount(); + this.views[opts.list+1].getEl().setHeight( this.innerLists[0].getHeight()); + this.views[opts.list+1].getEl().setStyle({ display : dl ? 'block' : 'none' }); + for (var i = opts.list+2; i < this.views.length;i++) { + this.views[i].getEl().setStyle({ display : 'none' }); + } + this.innerLists[opts.list+1].setHeight( this.innerLists[0].getHeight()); - this.list.setWidth(lw * (opts.list + (dl ? 2 : 1))); + this.list.setWidth(lw * (opts.list + (dl ? 2 : 1))); + + if (this.isLoading) { + // this.selectActive(opts.list); + } + }, + + + + onDoubleClick : function() { this.collapse(); //?? @@ -43027,13 +43067,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) + recordToStack : function(store, prop, value, stack) { var cstore = new Roo.data.SimpleStore({ //fields : this.store.reader.meta.fields, // we need array reader.. for @@ -43042,26 +43079,53 @@ Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, { }); var _this = this; var record = false; - if(store.getCount() > 0){ - store.each(function(r){ - if(r.data[prop] == value){ - record = r; + 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.recordToStack(cstore, prop, value, stack); + if (cret !== false) { + record = cret; + srec = 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 = cret; - return false; - } - } - - return true; - }); + } + + return true; + }); + if (record == false) { + return false } + stack.unshift(srec); return record; + }, + + /* + * find the stack of stores that match our value. + * + * + */ + + selectActive : function () + { + // if store is not loaded, then we will need to wait for that to happen first. + var stack = []; + this.recordToStack(this.store, this.valueField, this.getValue(), stack); + for (var i = 0; i < stack.length; i++ ) { + this.views[i].select(stack[i].store.indexOf(stack[i]), false, false ); + } + } + +