X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-ui-debug.js;h=0d2285db4934541b7eba8997eddca43036390323;hp=4ef5d5dc3c34167e4a812456c16ae06ad090e52f;hb=refs%2Fheads%2Fwip_alan_T6201_Category_select;hpb=bc057c36aa2b9e056c633661d60efaa6f3e2ab41 diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 4ef5d5dc3c..0d2285db49 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -784,6 +784,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. @@ -1274,6 +1284,9 @@ Roo.data.DataReader = function(meta, recordType){ }; Roo.data.DataReader.prototype = { + + + readerType : 'Data', /** * Create an empty record * @param {Object} data (optional) - overlay some values @@ -1294,6 +1307,7 @@ Roo.data.DataReader.prototype = { return new this.recordType(Roo.apply(da, d)); } + };/* * Based on: * Ext JS Library 1.1.1 @@ -1832,6 +1846,8 @@ Roo.data.JsonReader = function(meta, recordType){ }; Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, { + readerType : 'Json', + /** * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source. * Used by Store query builder to append _requestMeta to params. @@ -1973,6 +1989,14 @@ Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, { records : records, totalRecords : totalRecords }; + }, + // 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 { data : data, total : data.length }; + } });/* * Based on: @@ -2043,6 +2067,9 @@ Roo.data.XmlReader = function(meta, recordType){ Roo.data.XmlReader.superclass.constructor.call(this, meta, recordType||meta.fields); }; Roo.extend(Roo.data.XmlReader, Roo.data.DataReader, { + + readerType : 'Xml', + /** * This method is only used by a DataProxy which has retrieved data from a remote server. * @param {Object} response The XHR object which contains the parsed XML document. The response is expected @@ -2154,14 +2181,14 @@ var myReader = new Roo.data.ArrayReader({ * * created using {@link Roo.data.Record#create}. */ -Roo.data.ArrayReader = function(meta, recordType){ - - +Roo.data.ArrayReader = function(meta, recordType) +{ Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields); }; Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, { - /** + + /** * Create a data block containing Roo.data.Records from an XML document. * @param {Object} o An Array of row objects which represents the dataset. * @return {Object} A data block which is used by an {@link Roo.data.Store} object as @@ -2192,7 +2219,16 @@ Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, { records : records, totalRecords : records.length }; + }, + // used when loading children.. @see loadDataFromChildren + toLoadData: function(rec) + { + // expect rec just to be an array.. eg [a,b,c, [...] << cn ] + return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn; + } + + });/* * Based on: * Ext JS Library 1.1.1 @@ -20182,6 +20218,434 @@ Roo.extend(Roo.form.ComboBoxArray.Item, Roo.BoxComponent, { } } +});/* + * RooJS Library 1.1.1 + * Copyright(c) 2008-2011 Alan Knowles + * + * License - LGPL + */ + + +/** + * @class Roo.form.ComboNested + * @extends Roo.form.ComboBox + * A combobox for that allows selection of nested items in a list, + * eg. + * + * Book + * -> red + * -> green + * Table + * -> square + * ->red + * ->green + * -> rectangle + * ->green + * + * + * @constructor + * Create a new ComboNested + * @param {Object} config Configuration options + */ +Roo.form.ComboNested = function(config){ + Roo.form.ComboCheck.superclass.constructor.call(this, config); + // should verify some data... + // like + // hiddenName = required.. + // displayField = required + // valudField == required + var req= [ 'hiddenName', 'displayField', 'valueField' ]; + var _t = this; + Roo.each(req, function(e) { + if ((typeof(_t[e]) == 'undefined' ) || !_t[e].length) { + throw "Roo.form.ComboNested : missing value for: " + e; + } + }); + + +}; + +Roo.extend(Roo.form.ComboNested, Roo.form.ComboBox, { + + /* + * @config {Number} max Number of columns to show + */ + + maxColumns : 3, + + list : null, // the outermost div.. + innerLists : null, // the + 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){ + this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName, id: (this.hiddenId||this.hiddenName)}, + 'before', true); + this.hiddenField.value = + this.hiddenValue !== undefined ? this.hiddenValue : + this.value !== undefined ? this.value : ''; + + // prevent input submission + this.el.dom.removeAttribute('name'); + + + } + + if(Roo.isGecko){ + this.el.dom.setAttribute('autocomplete', 'off'); + } + + var cls = 'x-combo-list'; + + this.list = new Roo.Layer({ + shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false + }); + + var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth); + this.list.setWidth(lw); + this.list.swallowEvent('mousewheel'); + this.assetHeight = 0; + + if(this.title){ + this.header = this.list.createChild({cls:cls+'-hd', html: this.title}); + this.assetHeight += this.header.getHeight(); + } + this.innerLists = []; + this.views = []; + this.stores = []; + for (var i =0 ; i < this.maxColumns; i++) { + this.onRenderList( cls, i); + } + + // always needs footer, as we are going to have an 'OK' button. + this.footer = this.list.createChild({cls:cls+'-ft'}); + this.pageTb = new Roo.Toolbar(this.footer); + var _this = this; + this.pageTb.add( { + + text: 'Done', + handler: function() + { + _this.collapse(); + } + }); + + if ( this.allowBlank && !this.disableClear) { + + this.pageTb.add(new Roo.Toolbar.Fill(), { + cls: 'x-btn-icon x-btn-clear', + text: ' ', + handler: function() + { + _this.collapse(); + _this.clearValue(); + _this.onSelect(false, -1); + } + }); + } + if (this.footer) { + this.assetHeight += this.footer.getHeight(); + } + + }, + onRenderList : function ( cls, i) + { + + 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' + + var il = this.innerLists[i] = this.list.createChild({cls:cls+'-inner'}); + //il.on('mouseover', this.onViewOver, this, { list: i }); + //il.on('mousemove', this.onViewMove, this, { list: i }); + il.setWidth(lw); + il.setStyle({ 'overflow-x' : 'hidden'}); + + if(!this.tpl){ + this.tpl = new Roo.Template({ + html : '