a:148:{s:9:"#provides";s:29:"dojox.grid.compat._data.model";s:9:"#resource";s:26:"grid/compat/_data/model.js";s:9:"#requires";a:1:{i:0;a:2:{i:0;s:6:"common";i:1;s:30:"dojox.grid.compat._data.fields";}}s:21:"dojox.grid.data.Model";a:5:{s:4:"type";s:8:"Function";s:7:"summary";s:85:"Base abstract grid data model. Makes no assumptions about the structure of grid data.";s:10:"parameters";a:2:{s:8:"inFields";a:1:{s:4:"type";s:0:"";}s:6:"inData";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:142:" this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData);";s:9:"classlike";b:1;}s:27:"dojox.grid.data.Model.count";a:2:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.Model.updating";a:2:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.Model.observer";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inObserver";a:1:{s:4:"type";s:0:"";}s:8:"inPrefix";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:62:" this.observers.push({o: inObserver, p: inPrefix||'model' });";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Model.notObserver";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inObserver";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:127:" for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } }";s:7:"summary";s:0:"";}s:28:"dojox.grid.data.Model.notify";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:5:"inMsg";a:1:{s:4:"type";s:0:"";}s:6:"inArgs";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:139:" var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); }";s:7:"summary";s:0:"";}s:27:"dojox.grid.data.Model.clear";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:6:"source";s:42:" this.fields.clear(); this.clearData();";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Model.beginUpdate";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:6:"source";s:40:" this.notify("BeginUpdate", arguments);";s:7:"summary";s:0:"";}s:31:"dojox.grid.data.Model.endUpdate";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:6:"source";s:38:" this.notify("EndUpdate", arguments);";s:7:"summary";s:0:"";}s:31:"dojox.grid.data.Model.clearData";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:6:"source";s:21:" this.setData(null);";s:7:"summary";s:0:"";}s:28:"dojox.grid.data.Model.change";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:6:"source";s:35:" this.notify("Change", arguments);";s:7:"summary";s:0:"";}s:31:"dojox.grid.data.Model.insertion";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:6:"source";s:74:" this.notify("Insertion", arguments); this.notify("Change", arguments);";s:7:"summary";s:0:"";}s:29:"dojox.grid.data.Model.removal";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:6:"source";s:72:" this.notify("Removal", arguments); this.notify("Change", arguments);";s:7:"summary";s:0:"";}s:28:"dojox.grid.data.Model.insert";a:6:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:6:"inData";a:1:{s:4:"type";s:7:", index";}}s:6:"source";s:138:" if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true;";s:6:"chains";a:1:{s:4:"call";a:2:{i:0;s:12:"this._insert";i:1;s:14:"this.insertion";}}s:7:"summary";s:0:"";}s:28:"dojox.grid.data.Model.remove";a:6:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:6:"inData";a:1:{s:4:"type";s:7:", index";}}s:6:"source";s:118:" if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true;";s:6:"chains";a:1:{s:4:"call";a:2:{i:0;s:12:"this._remove";i:1;s:12:"this.removal";}}s:7:"summary";s:0:"";}s:29:"dojox.grid.data.Model.canSort";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:6:"source";s:27:" return this.sort != null;";s:7:"summary";s:0:"";}s:40:"dojox.grid.data.Model.generateComparator";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:10:"parameters";a:4:{s:9:"inCompare";a:1:{s:4:"type";s:0:"";}s:7:"inField";a:1:{s:4:"type";s:0:"";}s:15:"inTrueForAscend";a:1:{s:4:"type";s:0:"";}s:12:"inSubCompare";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:165:" return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); }";s:7:"summary";s:0:"";}s:36:"dojox.grid.data.Model.makeComparator";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"inIndices";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:290:" var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result;";s:7:"summary";s:0:"";}s:26:"dojox.grid.data.Model.sort";a:2:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:7:"summary";s:0:"";}s:27:"dojox.grid.data.Model.dummy";a:2:{s:9:"prototype";s:21:"dojox.grid.data.Model";s:7:"summary";s:0:"";}s:31:"dojox.grid.data.Model.observers";a:2:{s:8:"instance";s:21:"dojox.grid.data.Model";s:7:"summary";s:0:"";}s:28:"dojox.grid.data.Model.fields";a:2:{s:8:"instance";s:21:"dojox.grid.data.Model";s:7:"summary";s:0:"";}s:20:"dojox.grid.data.Rows";a:4:{s:4:"type";s:8:"Function";s:6:"chains";a:2:{s:9:"prototype";a:1:{i:0;s:21:"dojox.grid.data.Model";}s:4:"call";a:1:{i:0;s:21:"dojox.grid.data.Model";}}s:9:"classlike";b:1;s:7:"summary";s:0:"";}s:30:"dojox.grid.data.Rows.allChange";a:4:{s:9:"prototype";s:20:"dojox.grid.data.Rows";s:4:"type";s:8:"Function";s:6:"source";s:74:" this.notify("AllChange", arguments); this.notify("Change", arguments);";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.Rows.rowChange";a:4:{s:9:"prototype";s:20:"dojox.grid.data.Rows";s:4:"type";s:8:"Function";s:6:"source";s:38:" this.notify("RowChange", arguments);";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.Rows.datumChange";a:4:{s:9:"prototype";s:20:"dojox.grid.data.Rows";s:4:"type";s:8:"Function";s:6:"source";s:40:" this.notify("DatumChange", arguments);";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Rows.beginModifyRow";a:5:{s:9:"prototype";s:20:"dojox.grid.data.Rows";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:88:" if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); }";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Rows.endModifyRow";a:5:{s:9:"prototype";s:20:"dojox.grid.data.Rows";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:220:" var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; }";s:7:"summary";s:0:"";}s:36:"dojox.grid.data.Rows.cancelModifyRow";a:5:{s:9:"prototype";s:20:"dojox.grid.data.Rows";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:123:" var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; }";s:7:"summary";s:0:"";}s:21:"dojox.grid.data.Table";a:5:{s:4:"type";s:8:"Function";s:6:"chains";a:2:{s:9:"prototype";a:1:{i:0;s:20:"dojox.grid.data.Rows";}s:4:"call";a:1:{i:0;s:20:"dojox.grid.data.Rows";}}s:7:"summary";s:98:"Basic grid data model for static data in the form of an array of rows that are arrays of cell data";s:6:"source";s:18:" this.cache = [];";s:9:"classlike";b:1;}s:30:"dojox.grid.data.Table.colCount";a:3:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:8:"instance";s:21:"dojox.grid.data.Table";s:7:"summary";s:0:"";}s:26:"dojox.grid.data.Table.data";a:3:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:8:"instance";s:21:"dojox.grid.data.Table";s:7:"summary";s:0:"";}s:27:"dojox.grid.data.Table.cache";a:3:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:8:"instance";s:21:"dojox.grid.data.Table";s:7:"summary";s:0:"";}s:29:"dojox.grid.data.Table.measure";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:6:"source";s:120:" this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure");";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Table.getRowCount";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:6:"source";s:44:" return (this.data ? this.data.length : 0);";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Table.getColCount";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:6:"source";s:85:" return (this.data && this.data.length ? this.data[0].length : this.fields.count());";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.Table.badIndex";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:8:"inCaller";a:1:{s:4:"type";s:0:"";}s:12:"inDescriptor";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:51:" console.error('dojox.grid.data.Table: badIndex');";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Table.isGoodIndex";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:10:"inColIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:131:" return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount)));";s:7:"summary";s:0:"";}s:28:"dojox.grid.data.Table.getRow";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:31:" return this.data[inRowIndex];";s:7:"summary";s:0:"";}s:29:"dojox.grid.data.Table.copyRow";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:42:" return this.getRow(inRowIndex).slice(0);";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.Table.getDatum";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:10:"inColIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:43:" return this.data[inRowIndex][inColIndex];";s:7:"summary";s:0:"";}s:25:"dojox.grid.data.Table.get";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:6:"source";s:72:" throw('Plain "get" no longer supported. Use "getRow" or "getDatum".');";s:7:"summary";s:0:"";}s:29:"dojox.grid.data.Table.setData";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:6:"inData";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:49:" this.data = (inData || []); this.allChange();";s:7:"summary";s:0:"";}s:28:"dojox.grid.data.Table.setRow";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:6:"inData";a:1:{s:4:"type";s:0:"";}s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:88:" this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change();";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.Table.setDatum";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:7:"inDatum";a:1:{s:4:"type";s:0:"";}s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:10:"inColIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:99:" this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex);";s:7:"summary";s:0:"";}s:25:"dojox.grid.data.Table.set";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:6:"source";s:84:" throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".');";s:7:"summary";s:0:"";}s:29:"dojox.grid.data.Table.setRows";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:6:"inData";a:1:{s:4:"type";s:0:"";}s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:95:" for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true;";s:7:"private";b:1;s:7:"summary";s:0:"";}s:26:"dojox.grid.data.Table.sort";a:4:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:6:"source";s:49:" this.data.sort(this.makeComparator(arguments));";s:7:"summary";s:0:"";}s:26:"dojox.grid.data.Table.swap";a:5:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:8:"inIndexA";a:1:{s:4:"type";s:0:"";}s:8:"inIndexB";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:173:" dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change();";s:7:"summary";s:0:"";}s:27:"dojox.grid.data.Table.dummy";a:2:{s:9:"prototype";s:21:"dojox.grid.data.Table";s:7:"summary";s:0:"";}s:27:"dojox.grid.data.Table.count";a:2:{s:8:"instance";s:21:"dojox.grid.data.Table";s:7:"summary";s:0:"";}s:23:"dojox.grid.data.Objects";a:6:{s:4:"type";s:8:"Function";s:6:"chains";a:2:{s:9:"prototype";a:1:{i:0;s:21:"dojox.grid.data.Table";}s:4:"call";a:1:{i:0;s:21:"dojox.grid.data.Table";}}s:10:"parameters";a:3:{s:8:"inFields";a:1:{s:4:"type";s:0:"";}s:6:"inData";a:1:{s:4:"type";s:0:"";}s:5:"inKey";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:48:" if(!inFields){ this.autoAssignFields(); }";s:9:"classlike";b:1;s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Objects.allChange";a:4:{s:9:"prototype";s:23:"dojox.grid.data.Objects";s:4:"type";s:8:"Function";s:6:"source";s:59:" this.notify("FieldsChange"); this.inherited(arguments);";s:7:"summary";s:0:"";}s:40:"dojox.grid.data.Objects.autoAssignFields";a:4:{s:9:"prototype";s:23:"dojox.grid.data.Objects";s:4:"type";s:8:"Function";s:6:"source";s:152:" var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } }";s:7:"summary";s:0:"";}s:31:"dojox.grid.data.Objects.setData";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Objects";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:6:"inData";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:76:" this.data = (inData || []); this.autoAssignFields(); this.allChange();";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.Objects.getDatum";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Objects";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:10:"inColIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:64:" return this.data[inRowIndex][this.fields.get(inColIndex).key];";s:7:"summary";s:0:"";}s:28:"dojox.grid.data.Objects.data";a:2:{s:8:"instance";s:23:"dojox.grid.data.Objects";s:7:"summary";s:0:"";}s:23:"dojox.grid.data.Dynamic";a:5:{s:4:"type";s:8:"Function";s:6:"chains";a:2:{s:9:"prototype";a:1:{i:0;s:21:"dojox.grid.data.Table";}s:4:"call";a:1:{i:0;s:21:"dojox.grid.data.Table";}}s:7:"summary";s:162:"Grid data model for dynamic data such as data retrieved from a server. Retrieves data automatically when requested and provides notification when data is received";s:6:"source";s:36:" this.page = []; this.pages = [];";s:9:"classlike";b:1;}s:28:"dojox.grid.data.Dynamic.page";a:3:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:8:"instance";s:23:"dojox.grid.data.Dynamic";s:7:"summary";s:0:"";}s:29:"dojox.grid.data.Dynamic.pages";a:3:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:8:"instance";s:23:"dojox.grid.data.Dynamic";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Dynamic.rowsPerPage";a:2:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.Dynamic.requests";a:3:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:8:"instance";s:23:"dojox.grid.data.Dynamic";s:7:"summary";s:0:"";}s:27:"dojox.grid.data.Dynamic.bop";a:3:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:8:"instance";s:23:"dojox.grid.data.Dynamic";s:7:"summary";s:0:"";}s:27:"dojox.grid.data.Dynamic.eop";a:3:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:8:"instance";s:23:"dojox.grid.data.Dynamic";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Dynamic.clearData";a:4:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:6:"source";s:66:" this.pages = []; this.bop = this.eop = -1; this.setData([]);";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Dynamic.getRowCount";a:4:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:6:"source";s:20:" return this.count;";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Dynamic.getColCount";a:4:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:6:"source";s:29:" return this.fields.count();";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Dynamic.setRowCount";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:7:"inCount";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:40:" this.count = inCount; this.change();";s:7:"summary";s:0:"";}s:39:"dojox.grid.data.Dynamic.requestsPending";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"inBoolean";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:0:"";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Dynamic.rowToPage";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:85:" return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex);";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.Dynamic.pageToRow";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:11:"inPageIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:75:" return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex);";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Dynamic.requestRows";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:7:"inCount";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:160:" // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow";s:7:"summary";s:128:"stub. Fill in to perform actual data row fetching logic. The returning logic must provide the data back to the system via setRow";}s:36:"dojox.grid.data.Dynamic.rowsProvided";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:7:"inCount";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:80:" this.requests--; if(this.requests == 0){ this.requestsPending(false); }";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Dynamic.requestPage";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:11:"inPageIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:270:" var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); }";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.Dynamic.needPage";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:11:"inPageIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:104:" if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); }";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Dynamic.preparePage";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:10:"inColIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:237:" if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); }";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Dynamic.isRowLoaded";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:40:" return Boolean(this.data[inRowIndex]);";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.Dynamic.removePages";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:12:"inRowIndexes";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:132:" for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1;";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.Dynamic.remove";a:6:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:12:"inRowIndexes";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:98:" this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments);";s:6:"chains";a:1:{s:4:"call";a:1:{i:0;s:38:"dojox.grid.data.Table.prototype.remove";}}s:7:"summary";s:0:"";}s:30:"dojox.grid.data.Dynamic.getRow";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:97:" var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row;";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.Dynamic.getDatum";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:10:"inColIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:103:" var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na);";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.Dynamic.setDatum";a:5:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:7:"inDatum";a:1:{s:4:"type";s:0:"";}s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:10:"inColIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:259:" var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); }";s:7:"summary";s:0:"";}s:31:"dojox.grid.data.Dynamic.canSort";a:4:{s:9:"prototype";s:23:"dojox.grid.data.Dynamic";s:4:"type";s:8:"Function";s:6:"source";s:15:" return false;";s:7:"summary";s:0:"";}s:29:"dojox.grid.data.Dynamic.count";a:2:{s:8:"instance";s:23:"dojox.grid.data.Dynamic";s:7:"summary";s:0:"";}s:24:"dojox.grid.data.DojoData";a:7:{s:4:"type";s:8:"Function";s:6:"chains";a:2:{s:9:"prototype";a:1:{i:0;s:23:"dojox.grid.data.Dynamic";}s:4:"call";a:1:{i:0;s:23:"dojox.grid.data.Dynamic";}}s:7:"summary";s:189:"A grid data model for dynamic data retreived from a store which implements the dojo.data API set. Retrieves data automatically when requested and provides notification when data is received";s:11:"description";s:230:"This store subclasses the Dynamic grid data object in order to provide paginated data access support, notification and view updates for stores which support those features, and simple field/column mapping for all dojo.data stores.";s:10:"parameters";a:3:{s:8:"inFields";a:1:{s:4:"type";s:0:"";}s:6:"inData";a:1:{s:4:"type";s:0:"";}s:4:"args";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:646:" this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } }";s:9:"classlike";b:1;}s:38:"dojox.grid.data.DojoData.markupFactory";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:4:"args";a:1:{s:4:"type";s:0:"";}s:4:"node";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:56:" return new dojox.grid.data.DojoData(null, null, args);";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.DojoData.query";a:3:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.DojoData.store";a:3:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"summary";s:0:"";}s:45:"dojox.grid.data.DojoData._currentlyProcessing";a:4:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"private";b:1;s:7:"summary";s:0:"";}s:35:"dojox.grid.data.DojoData._canNotify";a:4:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"private";b:1;s:7:"summary";s:0:"";}s:34:"dojox.grid.data.DojoData._canWrite";a:4:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"private";b:1;s:7:"summary";s:0:"";}s:37:"dojox.grid.data.DojoData._canIdentify";a:4:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"private";b:1;s:7:"summary";s:0:"";}s:39:"dojox.grid.data.DojoData._rowIdentities";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:6:"Object";s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"private";b:1;s:7:"summary";s:0:"";}s:35:"dojox.grid.data.DojoData.clientSort";a:2:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:7:"summary";s:0:"";}s:35:"dojox.grid.data.DojoData.sortFields";a:3:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"summary";s:0:"";}s:37:"dojox.grid.data.DojoData.queryOptions";a:2:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.DojoData.setData";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:6:"inData";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:60:" this.store = inData; this.data = []; this.allChange();";s:7:"summary";s:0:"";}s:36:"dojox.grid.data.DojoData.setRowCount";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:7:"inCount";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:12174:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange();";s:7:"summary";s:0:"";}s:36:"dojox.grid.data.DojoData.beginReturn";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:7:"inCount";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:151:" if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); }";s:7:"summary";s:0:"";}s:37:"dojox.grid.data.DojoData._setupFields";a:6:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:8:"dataItem";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:12945:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange");";s:7:"private";b:1;s:7:"summary";s:0:"";}s:40:"dojox.grid.data.DojoData._getRowFromItem";a:6:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"item";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:13038:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange"); }, _getRowFromItem: function(item){ // gets us the row object (and row index) of an item";s:7:"private";b:1;s:7:"summary";s:0:"";}s:35:"dojox.grid.data.DojoData._createRow";a:6:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"item";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:238:" var row = {}; row.__dojo_data_item = item; dojo.forEach(this.fields.values, function(a){ var value = this.store.getValue(item, a.name); row[a.name] = (value === undefined || value === null)?"":value; }, this); return row;";s:7:"private";b:1;s:7:"summary";s:0:"";}s:36:"dojox.grid.data.DojoData.processRows";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:5:"items";a:1:{s:4:"type";s:0:"";}s:7:"request";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:13951:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange"); }, _getRowFromItem: function(item){ // gets us the row object (and row index) of an item }, _createRow: function(item){ var row = {}; row.__dojo_data_item = item; dojo.forEach(this.fields.values, function(a){ var value = this.store.getValue(item, a.name); row[a.name] = (value === undefined || value === null)?"":value; }, this); return row; }, processRows: function(items, request){ // console.debug(arguments); if(!items || items.length == 0){ return; } this._setupFields(items[0]); dojo.forEach(items, function(item, idx){ var row = this._createRow(item); this._setRowId(item, request.start, idx); this.setRow(row, request.start+idx); }, this); this.endUpdate(); // FIXME: // Q: scott, steve, how the hell do we actually get this to update // the visible UI for these rows? // A: the goal is that Grid automatically updates to reflect changes // in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow";s:7:"summary";s:0:"";}s:36:"dojox.grid.data.DojoData.requestRows";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:7:"inCount";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:387:" this.beginUpdate(); var row = inRowIndex || 0; var params = { start: row, count: this.rowsPerPage, query: this.query, sort: this.sortFields, queryOptions: this.queryOptions, onBegin: dojo.hitch(this, "beginReturn"), onComplete: dojo.hitch(this, "processRows"), // add to deferred? onError: dojo.hitch(this, "processError") }; this.store.fetch(params);";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.DojoData.getDatum";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:10:"inColIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:14784:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange"); }, _getRowFromItem: function(item){ // gets us the row object (and row index) of an item }, _createRow: function(item){ var row = {}; row.__dojo_data_item = item; dojo.forEach(this.fields.values, function(a){ var value = this.store.getValue(item, a.name); row[a.name] = (value === undefined || value === null)?"":value; }, this); return row; }, processRows: function(items, request){ // console.debug(arguments); if(!items || items.length == 0){ return; } this._setupFields(items[0]); dojo.forEach(items, function(item, idx){ var row = this._createRow(item); this._setRowId(item, request.start, idx); this.setRow(row, request.start+idx); }, this); this.endUpdate(); // FIXME: // Q: scott, steve, how the hell do we actually get this to update // the visible UI for these rows? // A: the goal is that Grid automatically updates to reflect changes // in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow }, // request data requestRows: function(inRowIndex, inCount){ this.beginUpdate(); var row = inRowIndex || 0; var params = { start: row, count: this.rowsPerPage, query: this.query, sort: this.sortFields, queryOptions: this.queryOptions, onBegin: dojo.hitch(this, "beginReturn"), onComplete: dojo.hitch(this, "processRows"), // add to deferred? onError: dojo.hitch(this, "processError") }; this.store.fetch(params); }, getDatum: function(inRowIndex, inColIndex){ //console.debug("getDatum", inRowIndex, inColIndex); var row = this.getRow(inRowIndex); var field = this.fields.values[inColIndex]; return row && field ? row[field.name] : field ? field.na : '?'; //var idx = row && this.fields._nameMaps[inColIndex+".idx"]; //return (row ? row[idx] : this.fields.get(inColIndex).na);";s:7:"summary";s:0:"";}s:33:"dojox.grid.data.DojoData.setDatum";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:7:"inDatum";a:1:{s:4:"type";s:0:"";}s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}s:10:"inColIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:231:" var n = this.fields._nameMaps[inColIndex+".idx"]; // console.debug("setDatum:", "n:"+n, inDatum, inRowIndex, inColIndex); if(n){ this.data[inRowIndex][n] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.DojoData.copyRow";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:168:" var row = {}; var backstop = {}; var src = this.getRow(inRowIndex); for(var x in src){ if(src[x] != backstop[x]){ row[x] = src[x]; } } return row;";s:7:"summary";s:0:"";}s:37:"dojox.grid.data.DojoData._attrCompare";a:6:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:5:"cache";a:1:{s:4:"type";s:0:"";}s:4:"data";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:128:" dojo.forEach(this.fields.values, function(a){ if(cache[a.name] != data[a.name]){ return false; } }, this); return true;";s:7:"private";b:1;s:7:"summary";s:0:"";}s:37:"dojox.grid.data.DojoData.endModifyRow";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:214:" var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!this._attrCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; }";s:7:"summary";s:0:"";}s:40:"dojox.grid.data.DojoData.cancelModifyRow";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:10:"inRowIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:15968:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange"); }, _getRowFromItem: function(item){ // gets us the row object (and row index) of an item }, _createRow: function(item){ var row = {}; row.__dojo_data_item = item; dojo.forEach(this.fields.values, function(a){ var value = this.store.getValue(item, a.name); row[a.name] = (value === undefined || value === null)?"":value; }, this); return row; }, processRows: function(items, request){ // console.debug(arguments); if(!items || items.length == 0){ return; } this._setupFields(items[0]); dojo.forEach(items, function(item, idx){ var row = this._createRow(item); this._setRowId(item, request.start, idx); this.setRow(row, request.start+idx); }, this); this.endUpdate(); // FIXME: // Q: scott, steve, how the hell do we actually get this to update // the visible UI for these rows? // A: the goal is that Grid automatically updates to reflect changes // in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow }, // request data requestRows: function(inRowIndex, inCount){ this.beginUpdate(); var row = inRowIndex || 0; var params = { start: row, count: this.rowsPerPage, query: this.query, sort: this.sortFields, queryOptions: this.queryOptions, onBegin: dojo.hitch(this, "beginReturn"), onComplete: dojo.hitch(this, "processRows"), // add to deferred? onError: dojo.hitch(this, "processError") }; this.store.fetch(params); }, getDatum: function(inRowIndex, inColIndex){ //console.debug("getDatum", inRowIndex, inColIndex); var row = this.getRow(inRowIndex); var field = this.fields.values[inColIndex]; return row && field ? row[field.name] : field ? field.na : '?'; //var idx = row && this.fields._nameMaps[inColIndex+".idx"]; //return (row ? row[idx] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var n = this.fields._nameMaps[inColIndex+".idx"]; // console.debug("setDatum:", "n:"+n, inDatum, inRowIndex, inColIndex); if(n){ this.data[inRowIndex][n] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); } }, // modification, update and store eventing copyRow: function(inRowIndex){ var row = {}; var backstop = {}; var src = this.getRow(inRowIndex); for(var x in src){ if(src[x] != backstop[x]){ row[x] = src[x]; } } return row; }, _attrCompare: function(cache, data){ dojo.forEach(this.fields.values, function(a){ if(cache[a.name] != data[a.name]){ return false; } }, this); return true; }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!this._attrCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ // console.debug("cancelModifyRow", arguments); var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; }";s:7:"summary";s:0:"";}s:34:"dojox.grid.data.DojoData._setRowId";a:6:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:4:"item";a:1:{s:4:"type";s:0:"";}s:6:"offset";a:1:{s:4:"type";s:0:"";}s:3:"idx";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:16466:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange"); }, _getRowFromItem: function(item){ // gets us the row object (and row index) of an item }, _createRow: function(item){ var row = {}; row.__dojo_data_item = item; dojo.forEach(this.fields.values, function(a){ var value = this.store.getValue(item, a.name); row[a.name] = (value === undefined || value === null)?"":value; }, this); return row; }, processRows: function(items, request){ // console.debug(arguments); if(!items || items.length == 0){ return; } this._setupFields(items[0]); dojo.forEach(items, function(item, idx){ var row = this._createRow(item); this._setRowId(item, request.start, idx); this.setRow(row, request.start+idx); }, this); this.endUpdate(); // FIXME: // Q: scott, steve, how the hell do we actually get this to update // the visible UI for these rows? // A: the goal is that Grid automatically updates to reflect changes // in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow }, // request data requestRows: function(inRowIndex, inCount){ this.beginUpdate(); var row = inRowIndex || 0; var params = { start: row, count: this.rowsPerPage, query: this.query, sort: this.sortFields, queryOptions: this.queryOptions, onBegin: dojo.hitch(this, "beginReturn"), onComplete: dojo.hitch(this, "processRows"), // add to deferred? onError: dojo.hitch(this, "processError") }; this.store.fetch(params); }, getDatum: function(inRowIndex, inColIndex){ //console.debug("getDatum", inRowIndex, inColIndex); var row = this.getRow(inRowIndex); var field = this.fields.values[inColIndex]; return row && field ? row[field.name] : field ? field.na : '?'; //var idx = row && this.fields._nameMaps[inColIndex+".idx"]; //return (row ? row[idx] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var n = this.fields._nameMaps[inColIndex+".idx"]; // console.debug("setDatum:", "n:"+n, inDatum, inRowIndex, inColIndex); if(n){ this.data[inRowIndex][n] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); } }, // modification, update and store eventing copyRow: function(inRowIndex){ var row = {}; var backstop = {}; var src = this.getRow(inRowIndex); for(var x in src){ if(src[x] != backstop[x]){ row[x] = src[x]; } } return row; }, _attrCompare: function(cache, data){ dojo.forEach(this.fields.values, function(a){ if(cache[a.name] != data[a.name]){ return false; } }, this); return true; }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!this._attrCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ // console.debug("cancelModifyRow", arguments); var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } }, _setRowId: function(item, offset, idx){ // FIXME: where else do we need to keep this in sync? //Handle stores that implement identity and try to handle those that do not. if (this._canIdentify) { this._rowIdentities[this.store.getIdentity(item)] = {rowId: offset+idx, item: item}; }else{ var identity = dojo.toJson(this.query) + ":start:" + offset + ":idx:" + idx + ":sort:" + dojo.toJson(this.sortFields); this._rowIdentities[identity] = {rowId: offset+idx, item: item}; }";s:7:"private";b:1;s:7:"summary";s:0:"";}s:34:"dojox.grid.data.DojoData._getRowId";a:6:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:4:"item";a:2:{s:4:"type";s:3:"The";s:7:"summary";s:45:"store item to examine to determine row index.";}s:9:"isNotItem";a:2:{s:4:"type";s:7:"Boolean";s:7:"summary";s:59:"flag to indicate if the item passed is a store item or not.";}}s:6:"source";s:697:" var rowId = null; //Handle identity and nonidentity capable stores. if(this._canIdentify && !isNotItem){ //Make sure the row in question is actually in our data view. If it isn't, //should just return null. var _rowId = this._rowIdentities[this.store.getIdentity(item)]; if(_rowId){ rowId = _rowId.rowId; } }else{ //Not efficient, but without identity support, //not a better way to do it. Basically, do our best to locate it //This may or may not work, but best we can do here. var id; for(id in this._rowIdentities){ if(this._rowIdentities[id].item === item){ rowId = this._rowIdentities[id].rowId; break; } } } return rowId;";s:7:"summary";s:54:"Function determine the row index for a particular item";s:7:"private";b:1;}s:42:"dojox.grid.data.DojoData._storeDatumChange";a:6:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:4:{s:4:"item";a:1:{s:4:"type";s:0:"";}s:4:"attr";a:1:{s:4:"type";s:0:"";}s:6:"oldVal";a:1:{s:4:"type";s:0:"";}s:6:"newVal";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:17782:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange"); }, _getRowFromItem: function(item){ // gets us the row object (and row index) of an item }, _createRow: function(item){ var row = {}; row.__dojo_data_item = item; dojo.forEach(this.fields.values, function(a){ var value = this.store.getValue(item, a.name); row[a.name] = (value === undefined || value === null)?"":value; }, this); return row; }, processRows: function(items, request){ // console.debug(arguments); if(!items || items.length == 0){ return; } this._setupFields(items[0]); dojo.forEach(items, function(item, idx){ var row = this._createRow(item); this._setRowId(item, request.start, idx); this.setRow(row, request.start+idx); }, this); this.endUpdate(); // FIXME: // Q: scott, steve, how the hell do we actually get this to update // the visible UI for these rows? // A: the goal is that Grid automatically updates to reflect changes // in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow }, // request data requestRows: function(inRowIndex, inCount){ this.beginUpdate(); var row = inRowIndex || 0; var params = { start: row, count: this.rowsPerPage, query: this.query, sort: this.sortFields, queryOptions: this.queryOptions, onBegin: dojo.hitch(this, "beginReturn"), onComplete: dojo.hitch(this, "processRows"), // add to deferred? onError: dojo.hitch(this, "processError") }; this.store.fetch(params); }, getDatum: function(inRowIndex, inColIndex){ //console.debug("getDatum", inRowIndex, inColIndex); var row = this.getRow(inRowIndex); var field = this.fields.values[inColIndex]; return row && field ? row[field.name] : field ? field.na : '?'; //var idx = row && this.fields._nameMaps[inColIndex+".idx"]; //return (row ? row[idx] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var n = this.fields._nameMaps[inColIndex+".idx"]; // console.debug("setDatum:", "n:"+n, inDatum, inRowIndex, inColIndex); if(n){ this.data[inRowIndex][n] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); } }, // modification, update and store eventing copyRow: function(inRowIndex){ var row = {}; var backstop = {}; var src = this.getRow(inRowIndex); for(var x in src){ if(src[x] != backstop[x]){ row[x] = src[x]; } } return row; }, _attrCompare: function(cache, data){ dojo.forEach(this.fields.values, function(a){ if(cache[a.name] != data[a.name]){ return false; } }, this); return true; }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!this._attrCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ // console.debug("cancelModifyRow", arguments); var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } }, _setRowId: function(item, offset, idx){ // FIXME: where else do we need to keep this in sync? //Handle stores that implement identity and try to handle those that do not. if (this._canIdentify) { this._rowIdentities[this.store.getIdentity(item)] = {rowId: offset+idx, item: item}; }else{ var identity = dojo.toJson(this.query) + ":start:" + offset + ":idx:" + idx + ":sort:" + dojo.toJson(this.sortFields); this._rowIdentities[identity] = {rowId: offset+idx, item: item}; } }, _getRowId: function(item, isNotItem){ // summary: // Function determine the row index for a particular item // item: // The store item to examine to determine row index. // isNotItem: // Boolean flag to indicate if the item passed is a store item or not. var rowId = null; //Handle identity and nonidentity capable stores. if(this._canIdentify && !isNotItem){ //Make sure the row in question is actually in our data view. If it isn't, //should just return null. var _rowId = this._rowIdentities[this.store.getIdentity(item)]; if(_rowId){ rowId = _rowId.rowId; } }else{ //Not efficient, but without identity support, //not a better way to do it. Basically, do our best to locate it //This may or may not work, but best we can do here. var id; for(id in this._rowIdentities){ if(this._rowIdentities[id].item === item){ rowId = this._rowIdentities[id].rowId; break; } } } return rowId; }, _storeDatumChange: function(item, attr, oldVal, newVal){ // the store has changed some data under us, need to update the display var rowId = this._getRowId(item); var row = this.getRow(rowId); if(row){ row[attr] = newVal; var colId = this.fields._nameMaps[attr]; this.notify("DatumChange", [ newVal, rowId, colId ]); }";s:7:"private";b:1;s:7:"summary";s:0:"";}s:42:"dojox.grid.data.DojoData._storeDatumDelete";a:6:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"item";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:322:" if(dojo.indexOf(this._currentlyProcessing, item) != -1) return; // the store has deleted some item under us, need to remove that item from // the view if possible. It may be the deleted item isn't even in the grid. var rowId = this._getRowId(item, true); if(rowId != null){ this._removeItems([rowId]); }";s:7:"private";b:1;s:7:"summary";s:0:"";}s:39:"dojox.grid.data.DojoData._storeDatumNew";a:6:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"item";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:155:" if(this._disableNew){ return; } // the store has added some item under us, need to add it to the view. this._insertItem(item, this.data.length);";s:7:"private";b:1;s:7:"summary";s:0:"";}s:31:"dojox.grid.data.DojoData.insert";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:4:"item";a:1:{s:4:"type";s:0:"";}s:5:"index";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:18538:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange"); }, _getRowFromItem: function(item){ // gets us the row object (and row index) of an item }, _createRow: function(item){ var row = {}; row.__dojo_data_item = item; dojo.forEach(this.fields.values, function(a){ var value = this.store.getValue(item, a.name); row[a.name] = (value === undefined || value === null)?"":value; }, this); return row; }, processRows: function(items, request){ // console.debug(arguments); if(!items || items.length == 0){ return; } this._setupFields(items[0]); dojo.forEach(items, function(item, idx){ var row = this._createRow(item); this._setRowId(item, request.start, idx); this.setRow(row, request.start+idx); }, this); this.endUpdate(); // FIXME: // Q: scott, steve, how the hell do we actually get this to update // the visible UI for these rows? // A: the goal is that Grid automatically updates to reflect changes // in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow }, // request data requestRows: function(inRowIndex, inCount){ this.beginUpdate(); var row = inRowIndex || 0; var params = { start: row, count: this.rowsPerPage, query: this.query, sort: this.sortFields, queryOptions: this.queryOptions, onBegin: dojo.hitch(this, "beginReturn"), onComplete: dojo.hitch(this, "processRows"), // add to deferred? onError: dojo.hitch(this, "processError") }; this.store.fetch(params); }, getDatum: function(inRowIndex, inColIndex){ //console.debug("getDatum", inRowIndex, inColIndex); var row = this.getRow(inRowIndex); var field = this.fields.values[inColIndex]; return row && field ? row[field.name] : field ? field.na : '?'; //var idx = row && this.fields._nameMaps[inColIndex+".idx"]; //return (row ? row[idx] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var n = this.fields._nameMaps[inColIndex+".idx"]; // console.debug("setDatum:", "n:"+n, inDatum, inRowIndex, inColIndex); if(n){ this.data[inRowIndex][n] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); } }, // modification, update and store eventing copyRow: function(inRowIndex){ var row = {}; var backstop = {}; var src = this.getRow(inRowIndex); for(var x in src){ if(src[x] != backstop[x]){ row[x] = src[x]; } } return row; }, _attrCompare: function(cache, data){ dojo.forEach(this.fields.values, function(a){ if(cache[a.name] != data[a.name]){ return false; } }, this); return true; }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!this._attrCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ // console.debug("cancelModifyRow", arguments); var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } }, _setRowId: function(item, offset, idx){ // FIXME: where else do we need to keep this in sync? //Handle stores that implement identity and try to handle those that do not. if (this._canIdentify) { this._rowIdentities[this.store.getIdentity(item)] = {rowId: offset+idx, item: item}; }else{ var identity = dojo.toJson(this.query) + ":start:" + offset + ":idx:" + idx + ":sort:" + dojo.toJson(this.sortFields); this._rowIdentities[identity] = {rowId: offset+idx, item: item}; } }, _getRowId: function(item, isNotItem){ // summary: // Function determine the row index for a particular item // item: // The store item to examine to determine row index. // isNotItem: // Boolean flag to indicate if the item passed is a store item or not. var rowId = null; //Handle identity and nonidentity capable stores. if(this._canIdentify && !isNotItem){ //Make sure the row in question is actually in our data view. If it isn't, //should just return null. var _rowId = this._rowIdentities[this.store.getIdentity(item)]; if(_rowId){ rowId = _rowId.rowId; } }else{ //Not efficient, but without identity support, //not a better way to do it. Basically, do our best to locate it //This may or may not work, but best we can do here. var id; for(id in this._rowIdentities){ if(this._rowIdentities[id].item === item){ rowId = this._rowIdentities[id].rowId; break; } } } return rowId; }, _storeDatumChange: function(item, attr, oldVal, newVal){ // the store has changed some data under us, need to update the display var rowId = this._getRowId(item); var row = this.getRow(rowId); if(row){ row[attr] = newVal; var colId = this.fields._nameMaps[attr]; this.notify("DatumChange", [ newVal, rowId, colId ]); } }, _storeDatumDelete: function(item){ if(dojo.indexOf(this._currentlyProcessing, item) != -1) return; // the store has deleted some item under us, need to remove that item from // the view if possible. It may be the deleted item isn't even in the grid. var rowId = this._getRowId(item, true); if(rowId != null){ this._removeItems([rowId]); } }, _storeDatumNew: function(item){ if(this._disableNew){ return; } // the store has added some item under us, need to add it to the view. this._insertItem(item, this.data.length); }, insert: function(item, index){ // Push the given item back to the store this._disableNew = true; var i = this.store.newItem(item); this._disableNew = false; this._insertItem(i, index);";s:7:"summary";s:0:"";}s:36:"dojox.grid.data.DojoData._insertItem";a:7:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:9:"storeItem";a:1:{s:4:"type";s:0:"";}s:5:"index";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:19042:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange"); }, _getRowFromItem: function(item){ // gets us the row object (and row index) of an item }, _createRow: function(item){ var row = {}; row.__dojo_data_item = item; dojo.forEach(this.fields.values, function(a){ var value = this.store.getValue(item, a.name); row[a.name] = (value === undefined || value === null)?"":value; }, this); return row; }, processRows: function(items, request){ // console.debug(arguments); if(!items || items.length == 0){ return; } this._setupFields(items[0]); dojo.forEach(items, function(item, idx){ var row = this._createRow(item); this._setRowId(item, request.start, idx); this.setRow(row, request.start+idx); }, this); this.endUpdate(); // FIXME: // Q: scott, steve, how the hell do we actually get this to update // the visible UI for these rows? // A: the goal is that Grid automatically updates to reflect changes // in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow }, // request data requestRows: function(inRowIndex, inCount){ this.beginUpdate(); var row = inRowIndex || 0; var params = { start: row, count: this.rowsPerPage, query: this.query, sort: this.sortFields, queryOptions: this.queryOptions, onBegin: dojo.hitch(this, "beginReturn"), onComplete: dojo.hitch(this, "processRows"), // add to deferred? onError: dojo.hitch(this, "processError") }; this.store.fetch(params); }, getDatum: function(inRowIndex, inColIndex){ //console.debug("getDatum", inRowIndex, inColIndex); var row = this.getRow(inRowIndex); var field = this.fields.values[inColIndex]; return row && field ? row[field.name] : field ? field.na : '?'; //var idx = row && this.fields._nameMaps[inColIndex+".idx"]; //return (row ? row[idx] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var n = this.fields._nameMaps[inColIndex+".idx"]; // console.debug("setDatum:", "n:"+n, inDatum, inRowIndex, inColIndex); if(n){ this.data[inRowIndex][n] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); } }, // modification, update and store eventing copyRow: function(inRowIndex){ var row = {}; var backstop = {}; var src = this.getRow(inRowIndex); for(var x in src){ if(src[x] != backstop[x]){ row[x] = src[x]; } } return row; }, _attrCompare: function(cache, data){ dojo.forEach(this.fields.values, function(a){ if(cache[a.name] != data[a.name]){ return false; } }, this); return true; }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!this._attrCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ // console.debug("cancelModifyRow", arguments); var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } }, _setRowId: function(item, offset, idx){ // FIXME: where else do we need to keep this in sync? //Handle stores that implement identity and try to handle those that do not. if (this._canIdentify) { this._rowIdentities[this.store.getIdentity(item)] = {rowId: offset+idx, item: item}; }else{ var identity = dojo.toJson(this.query) + ":start:" + offset + ":idx:" + idx + ":sort:" + dojo.toJson(this.sortFields); this._rowIdentities[identity] = {rowId: offset+idx, item: item}; } }, _getRowId: function(item, isNotItem){ // summary: // Function determine the row index for a particular item // item: // The store item to examine to determine row index. // isNotItem: // Boolean flag to indicate if the item passed is a store item or not. var rowId = null; //Handle identity and nonidentity capable stores. if(this._canIdentify && !isNotItem){ //Make sure the row in question is actually in our data view. If it isn't, //should just return null. var _rowId = this._rowIdentities[this.store.getIdentity(item)]; if(_rowId){ rowId = _rowId.rowId; } }else{ //Not efficient, but without identity support, //not a better way to do it. Basically, do our best to locate it //This may or may not work, but best we can do here. var id; for(id in this._rowIdentities){ if(this._rowIdentities[id].item === item){ rowId = this._rowIdentities[id].rowId; break; } } } return rowId; }, _storeDatumChange: function(item, attr, oldVal, newVal){ // the store has changed some data under us, need to update the display var rowId = this._getRowId(item); var row = this.getRow(rowId); if(row){ row[attr] = newVal; var colId = this.fields._nameMaps[attr]; this.notify("DatumChange", [ newVal, rowId, colId ]); } }, _storeDatumDelete: function(item){ if(dojo.indexOf(this._currentlyProcessing, item) != -1) return; // the store has deleted some item under us, need to remove that item from // the view if possible. It may be the deleted item isn't even in the grid. var rowId = this._getRowId(item, true); if(rowId != null){ this._removeItems([rowId]); } }, _storeDatumNew: function(item){ if(this._disableNew){ return; } // the store has added some item under us, need to add it to the view. this._insertItem(item, this.data.length); }, insert: function(item, index){ // Push the given item back to the store this._disableNew = true; var i = this.store.newItem(item); this._disableNew = false; this._insertItem(i, index); }, _insertItem: function(storeItem, index){ // Set up our fields if we haven't already if(!this.fields._nameMaps){ this._setupFields(storeItem); } var row = this._createRow(storeItem); for(var i in this._rowIdentities){ //increment all the remaining row ids up one var rowIdentity = this._rowIdentities[i]; if(rowIdentity.rowId >= index){ rowIdentity.rowId++; } } this._setRowId(storeItem, 0, index); dojox.grid.data.Dynamic.prototype.insert.apply(this, [row, index]);";s:6:"chains";a:1:{s:4:"call";a:1:{i:0;s:40:"dojox.grid.data.Dynamic.prototype.insert";}}s:7:"private";b:1;s:7:"summary";s:0:"";}s:36:"dojox.grid.data.DojoData.datumChange";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:5:"value";a:1:{s:4:"type";s:0:"";}s:6:"rowIdx";a:1:{s:4:"type";s:0:"";}s:6:"colIdx";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:482:" if(this._canWrite){ // we're chaning some data, which means we need to write back var row = this.getRow(rowIdx); var field = this.fields._nameMaps[colIdx+".idx"]; this.store.setValue(row.__dojo_data_item, field, value); // we don't need to call DatumChange, an eventing store will tell // us about the row change events }else{ // we can't write back, so just go ahead and change our local copy // of the data this.notify("DatumChange", arguments); }";s:7:"summary";s:0:"";}s:34:"dojox.grid.data.DojoData.insertion";a:4:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:6:"source";s:74:" this.notify("Insertion", arguments); this.notify("Change", arguments);";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.DojoData.removal";a:4:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:6:"source";s:72:" this.notify("Removal", arguments); this.notify("Change", arguments);";s:7:"summary";s:0:"";}s:31:"dojox.grid.data.DojoData.remove";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:12:"inRowIndexes";a:2:{s:4:"type";s:2:"An";s:7:"summary";s:85:"array of row indexes from the grid to remove from the store. Call delete on the store";}}s:6:"source";s:374:" for(var i=inRowIndexes.length-1; i>=0; i--){ // Need to find the item, then remove each from the data store var item = this.data[inRowIndexes[i]].__dojo_data_item; this._currentlyProcessing.push(item); this.store.deleteItem(item); } /* Remove from internal data structure and the view */ this._removeItems(inRowIndexes); this._currentlyProcessing = [];";s:7:"summary";s:72:"Function to remove a set of items from the store based on the row index.";}s:37:"dojox.grid.data.DojoData._removeItems";a:7:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:12:"inRowIndexes";a:2:{s:4:"type";s:5:"array";s:7:"summary";s:63:"An array of row indexes from the grid to remove from the store.";}}s:6:"source";s:228:" dojox.grid.data.Dynamic.prototype.remove.apply(this, arguments); // Rebuild _rowIdentities this._rowIdentities = {}; for (var i = 0; i < this.data.length; i++){ this._setRowId(this.data[i].__dojo_data_item, 0, i); }";s:7:"summary";s:72:"Function to remove a set of items from the store based on the row index.";s:6:"chains";a:1:{s:4:"call";a:1:{i:0;s:40:"dojox.grid.data.Dynamic.prototype.remove";}}s:7:"private";b:1;}s:32:"dojox.grid.data.DojoData.canSort";a:4:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:6:"source";s:21076:"dojo.provide('dojox.grid.compat._data.model'); dojo.require('dojox.grid.compat._data.fields'); dojo.declare("dojox.grid.data.Model", null, { // summary: // Base abstract grid data model. // Makes no assumptions about the structure of grid data. constructor: function(inFields, inData){ this.observers = []; this.fields = new dojox.grid.data.Fields(); if(inFields){ this.fields.set(inFields); } this.setData(inData); }, count: 0, updating: 0, // observers observer: function(inObserver, inPrefix){ this.observers.push({o: inObserver, p: inPrefix||'model' }); }, notObserver: function(inObserver){ for(var i=0, m, o; (o=this.observers[i]); i++){ if(o.o==inObserver){ this.observers.splice(i, 1); return; } } }, notify: function(inMsg, inArgs){ var a = inArgs || []; for(var i=0, m, o; (o=this.observers[i]); i++){ m = o.p + inMsg; o = o.o; (m in o)&&(o[m].apply(o, a)); } }, // updates clear: function(){ this.fields.clear(); this.clearData(); }, beginUpdate: function(){ this.notify("BeginUpdate", arguments); }, endUpdate: function(){ this.notify("EndUpdate", arguments); }, // data clearData: function(){ this.setData(null); }, // observer events change: function(){ this.notify("Change", arguments); }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, // insert insert: function(inData /*, index */){ if(!this._insert.apply(this, arguments)){ return false; } this.insertion.apply(this, dojo._toArray(arguments, 1)); return true; }, // remove remove: function(inData /*, index */){ if(!this._remove.apply(this, arguments)){ return false; } this.removal.apply(this, arguments); return true; }, // sort canSort: function(/* (+|-)column_index+1, ... */){ return this.sort != null; }, generateComparator: function(inCompare, inField, inTrueForAscend, inSubCompare){ return function(a, b){ var ineq = inCompare(a[inField], b[inField]); return ineq ? (inTrueForAscend ? ineq : -ineq) : inSubCompare && inSubCompare(a, b); } }, makeComparator: function(inIndices){ var idx, col, field, result = null; for(var i=inIndices.length-1; i>=0; i--){ idx = inIndices[i]; col = Math.abs(idx) - 1; if(col >= 0){ field = this.fields.get(col); result = this.generateComparator(field.compare, field.key, idx > 0, result); } } return result; }, sort: null, dummy: 0 }); dojo.declare("dojox.grid.data.Rows", dojox.grid.data.Model, { // observer events allChange: function(){ this.notify("AllChange", arguments); this.notify("Change", arguments); }, rowChange: function(){ this.notify("RowChange", arguments); }, datumChange: function(){ this.notify("DatumChange", arguments); }, // copyRow: function(inRowIndex); // abstract // update beginModifyRow: function(inRowIndex){ if(!this.cache[inRowIndex]){ this.cache[inRowIndex] = this.copyRow(inRowIndex); } }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!dojox.grid.arrayCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } } }); dojo.declare("dojox.grid.data.Table", dojox.grid.data.Rows, { // summary: // Basic grid data model for static data in the form of an array of rows // that are arrays of cell data constructor: function(){ this.cache = []; }, colCount: 0, // tables introduce cols data: null, cache: null, // morphology measure: function(){ this.count = this.getRowCount(); this.colCount = this.getColCount(); this.allChange(); //this.notify("Measure"); }, getRowCount: function(){ return (this.data ? this.data.length : 0); }, getColCount: function(){ return (this.data && this.data.length ? this.data[0].length : this.fields.count()); }, badIndex: function(inCaller, inDescriptor){ console.error('dojox.grid.data.Table: badIndex'); }, isGoodIndex: function(inRowIndex, inColIndex){ return (inRowIndex >= 0 && inRowIndex < this.count && (arguments.length < 2 || (inColIndex >= 0 && inColIndex < this.colCount))); }, // access getRow: function(inRowIndex){ return this.data[inRowIndex]; }, copyRow: function(inRowIndex){ return this.getRow(inRowIndex).slice(0); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][inColIndex]; }, get: function(){ throw('Plain "get" no longer supported. Use "getRow" or "getDatum".'); }, setData: function(inData){ this.data = (inData || []); this.allChange(); }, setRow: function(inData, inRowIndex){ this.data[inRowIndex] = inData; this.rowChange(inData, inRowIndex); this.change(); }, setDatum: function(inDatum, inRowIndex, inColIndex){ this.data[inRowIndex][inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }, set: function(){ throw('Plain "set" no longer supported. Use "setData", "setRow", or "setDatum".'); }, setRows: function(inData, inRowIndex){ for(var i=0, l=inData.length, r=inRowIndex; i=0; i--){ dojox.grid.arrayRemove(this.data, inKeys[i]); } this.count -= inKeys.length; return true; }, // sort sort: function(/* (+|-)column_index+1, ... */){ this.data.sort(this.makeComparator(arguments)); }, swap: function(inIndexA, inIndexB){ dojox.grid.arraySwap(this.data, inIndexA, inIndexB); this.rowChange(this.getRow(inIndexA), inIndexA); this.rowChange(this.getRow(inIndexB), inIndexB); this.change(); }, dummy: 0 }); dojo.declare("dojox.grid.data.Objects", dojox.grid.data.Table, { constructor: function(inFields, inData, inKey){ if(!inFields){ this.autoAssignFields(); } }, allChange: function(){ this.notify("FieldsChange"); this.inherited(arguments); }, autoAssignFields: function(){ var d = this.data[0], i = 0, field; for(var f in d){ field = this.fields.get(i++); if (!dojo.isString(field.key)){ field.key = f; } } }, setData: function(inData){ this.data = (inData || []); this.autoAssignFields(); this.allChange(); }, getDatum: function(inRowIndex, inColIndex){ return this.data[inRowIndex][this.fields.get(inColIndex).key]; } }); dojo.declare("dojox.grid.data.Dynamic", dojox.grid.data.Table, { // summary: // Grid data model for dynamic data such as data retrieved from a server. // Retrieves data automatically when requested and provides notification when data is received constructor: function(){ this.page = []; this.pages = []; }, page: null, pages: null, rowsPerPage: 100, requests: 0, bop: -1, eop: -1, // data clearData: function(){ this.pages = []; this.bop = this.eop = -1; this.setData([]); }, getRowCount: function(){ return this.count; }, getColCount: function(){ return this.fields.count(); }, setRowCount: function(inCount){ this.count = inCount; this.change(); }, // paging requestsPending: function(inBoolean){ }, rowToPage: function(inRowIndex){ return (this.rowsPerPage ? Math.floor(inRowIndex / this.rowsPerPage) : inRowIndex); }, pageToRow: function(inPageIndex){ return (this.rowsPerPage ? this.rowsPerPage * inPageIndex : inPageIndex); }, requestRows: function(inRowIndex, inCount){ // summary: // stub. Fill in to perform actual data row fetching logic. The // returning logic must provide the data back to the system via // setRow }, rowsProvided: function(inRowIndex, inCount){ this.requests--; if(this.requests == 0){ this.requestsPending(false); } }, requestPage: function(inPageIndex){ var row = this.pageToRow(inPageIndex); var count = Math.min(this.rowsPerPage, this.count - row); if(count > 0){ this.requests++; this.requestsPending(true); setTimeout(dojo.hitch(this, "requestRows", row, count), 1); //this.requestRows(row, count); } }, needPage: function(inPageIndex){ if(!this.pages[inPageIndex]){ this.pages[inPageIndex] = true; this.requestPage(inPageIndex); } }, preparePage: function(inRowIndex, inColIndex){ if(inRowIndex < this.bop || inRowIndex >= this.eop){ var pageIndex = this.rowToPage(inRowIndex); this.needPage(pageIndex); this.bop = pageIndex * this.rowsPerPage; this.eop = this.bop + (this.rowsPerPage || this.count); } }, isRowLoaded: function(inRowIndex){ return Boolean(this.data[inRowIndex]); }, // removal removePages: function(inRowIndexes){ for(var i=0, r; ((r=inRowIndexes[i]) != undefined); i++){ this.pages[this.rowToPage(r)] = false; } this.bop = this.eop =-1; }, remove: function(inRowIndexes){ this.removePages(inRowIndexes); dojox.grid.data.Table.prototype.remove.apply(this, arguments); }, // access getRow: function(inRowIndex){ var row = this.data[inRowIndex]; if(!row){ this.preparePage(inRowIndex); } return row; }, getDatum: function(inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); return (row ? row[inColIndex] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var row = this.getRow(inRowIndex); if(row){ row[inColIndex] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); }else{ console.error('[' + this.declaredClass + '] dojox.grid.data.dynamic.set: cannot set data on a non-loaded row'); } }, // sort canSort: function(){ return false; } }); // FIXME: deprecated: (included for backward compatibility only) dojox.grid.data.table = dojox.grid.data.Table; dojox.grid.data.dynamic = dojox.grid.data.Dynamic; // we treat dojo.data stores as dynamic stores because no matter how they got // here, they should always fill that contract dojo.declare("dojox.grid.data.DojoData", dojox.grid.data.Dynamic, { // summary: // A grid data model for dynamic data retreived from a store which // implements the dojo.data API set. Retrieves data automatically when // requested and provides notification when data is received // description: // This store subclasses the Dynamic grid data object in order to // provide paginated data access support, notification and view // updates for stores which support those features, and simple // field/column mapping for all dojo.data stores. constructor: function(inFields, inData, args){ this.count = 1; this._rowIdentities = {}; this._currentlyProcessing = []; if(args){ dojo.mixin(this, args); } if(this.store){ var f = this.store.getFeatures(); this._canNotify = f['dojo.data.api.Notification']; this._canWrite = f['dojo.data.api.Write']; this._canIdentify = f['dojo.data.api.Identity']; if(this._canNotify){ dojo.connect(this.store, "onSet", this, "_storeDatumChange"); dojo.connect(this.store, "onDelete", this, "_storeDatumDelete"); dojo.connect(this.store, "onNew", this, "_storeDatumNew"); } if(this._canWrite) { dojo.connect(this.store, "revert", this, "refresh"); } } }, markupFactory: function(args, node){ return new dojox.grid.data.DojoData(null, null, args); }, query: { name: "*" }, // default, stupid query store: null, _currentlyProcessing: null, _canNotify: false, _canWrite: false, _canIdentify: false, _rowIdentities: {}, clientSort: false, sortFields: null, queryOptions: null, // data setData: function(inData){ this.store = inData; this.data = []; this.allChange(); }, setRowCount: function(inCount){ //console.debug("inCount:", inCount); this.count = inCount; this.allChange(); }, beginReturn: function(inCount){ if(this.count != inCount){ // this.setRowCount(0); // this.clear(); // console.debug(this.count, inCount); this.setRowCount(inCount); } }, _setupFields: function(dataItem){ // abort if we already have setup fields if(this.fields._nameMaps){ return; } // set up field/index mappings var m = {}; //console.debug("setting up fields", m); var fields = dojo.map(this.store.getAttributes(dataItem), function(item, idx){ m[item] = idx; m[idx+".idx"] = item; // name == display name, key = property name return { name: item, key: item }; }, this ); this.fields._nameMaps = m; // console.debug("new fields:", fields); this.fields.set(fields); this.notify("FieldsChange"); }, _getRowFromItem: function(item){ // gets us the row object (and row index) of an item }, _createRow: function(item){ var row = {}; row.__dojo_data_item = item; dojo.forEach(this.fields.values, function(a){ var value = this.store.getValue(item, a.name); row[a.name] = (value === undefined || value === null)?"":value; }, this); return row; }, processRows: function(items, request){ // console.debug(arguments); if(!items || items.length == 0){ return; } this._setupFields(items[0]); dojo.forEach(items, function(item, idx){ var row = this._createRow(item); this._setRowId(item, request.start, idx); this.setRow(row, request.start+idx); }, this); this.endUpdate(); // FIXME: // Q: scott, steve, how the hell do we actually get this to update // the visible UI for these rows? // A: the goal is that Grid automatically updates to reflect changes // in model. In this case, setRow -> rowChanged -> (observed by) Grid -> modelRowChange -> updateRow }, // request data requestRows: function(inRowIndex, inCount){ this.beginUpdate(); var row = inRowIndex || 0; var params = { start: row, count: this.rowsPerPage, query: this.query, sort: this.sortFields, queryOptions: this.queryOptions, onBegin: dojo.hitch(this, "beginReturn"), onComplete: dojo.hitch(this, "processRows"), // add to deferred? onError: dojo.hitch(this, "processError") }; this.store.fetch(params); }, getDatum: function(inRowIndex, inColIndex){ //console.debug("getDatum", inRowIndex, inColIndex); var row = this.getRow(inRowIndex); var field = this.fields.values[inColIndex]; return row && field ? row[field.name] : field ? field.na : '?'; //var idx = row && this.fields._nameMaps[inColIndex+".idx"]; //return (row ? row[idx] : this.fields.get(inColIndex).na); }, setDatum: function(inDatum, inRowIndex, inColIndex){ var n = this.fields._nameMaps[inColIndex+".idx"]; // console.debug("setDatum:", "n:"+n, inDatum, inRowIndex, inColIndex); if(n){ this.data[inRowIndex][n] = inDatum; this.datumChange(inDatum, inRowIndex, inColIndex); } }, // modification, update and store eventing copyRow: function(inRowIndex){ var row = {}; var backstop = {}; var src = this.getRow(inRowIndex); for(var x in src){ if(src[x] != backstop[x]){ row[x] = src[x]; } } return row; }, _attrCompare: function(cache, data){ dojo.forEach(this.fields.values, function(a){ if(cache[a.name] != data[a.name]){ return false; } }, this); return true; }, endModifyRow: function(inRowIndex){ var cache = this.cache[inRowIndex]; if(cache){ var data = this.getRow(inRowIndex); if(!this._attrCompare(cache, data)){ this.update(cache, data, inRowIndex); } delete this.cache[inRowIndex]; } }, cancelModifyRow: function(inRowIndex){ // console.debug("cancelModifyRow", arguments); var cache = this.cache[inRowIndex]; if(cache){ this.setRow(cache, inRowIndex); delete this.cache[inRowIndex]; } }, _setRowId: function(item, offset, idx){ // FIXME: where else do we need to keep this in sync? //Handle stores that implement identity and try to handle those that do not. if (this._canIdentify) { this._rowIdentities[this.store.getIdentity(item)] = {rowId: offset+idx, item: item}; }else{ var identity = dojo.toJson(this.query) + ":start:" + offset + ":idx:" + idx + ":sort:" + dojo.toJson(this.sortFields); this._rowIdentities[identity] = {rowId: offset+idx, item: item}; } }, _getRowId: function(item, isNotItem){ // summary: // Function determine the row index for a particular item // item: // The store item to examine to determine row index. // isNotItem: // Boolean flag to indicate if the item passed is a store item or not. var rowId = null; //Handle identity and nonidentity capable stores. if(this._canIdentify && !isNotItem){ //Make sure the row in question is actually in our data view. If it isn't, //should just return null. var _rowId = this._rowIdentities[this.store.getIdentity(item)]; if(_rowId){ rowId = _rowId.rowId; } }else{ //Not efficient, but without identity support, //not a better way to do it. Basically, do our best to locate it //This may or may not work, but best we can do here. var id; for(id in this._rowIdentities){ if(this._rowIdentities[id].item === item){ rowId = this._rowIdentities[id].rowId; break; } } } return rowId; }, _storeDatumChange: function(item, attr, oldVal, newVal){ // the store has changed some data under us, need to update the display var rowId = this._getRowId(item); var row = this.getRow(rowId); if(row){ row[attr] = newVal; var colId = this.fields._nameMaps[attr]; this.notify("DatumChange", [ newVal, rowId, colId ]); } }, _storeDatumDelete: function(item){ if(dojo.indexOf(this._currentlyProcessing, item) != -1) return; // the store has deleted some item under us, need to remove that item from // the view if possible. It may be the deleted item isn't even in the grid. var rowId = this._getRowId(item, true); if(rowId != null){ this._removeItems([rowId]); } }, _storeDatumNew: function(item){ if(this._disableNew){ return; } // the store has added some item under us, need to add it to the view. this._insertItem(item, this.data.length); }, insert: function(item, index){ // Push the given item back to the store this._disableNew = true; var i = this.store.newItem(item); this._disableNew = false; this._insertItem(i, index); }, _insertItem: function(storeItem, index){ // Set up our fields if we haven't already if(!this.fields._nameMaps){ this._setupFields(storeItem); } var row = this._createRow(storeItem); for(var i in this._rowIdentities){ //increment all the remaining row ids up one var rowIdentity = this._rowIdentities[i]; if(rowIdentity.rowId >= index){ rowIdentity.rowId++; } } this._setRowId(storeItem, 0, index); dojox.grid.data.Dynamic.prototype.insert.apply(this, [row, index]); }, datumChange: function(value, rowIdx, colIdx){ if(this._canWrite){ // we're chaning some data, which means we need to write back var row = this.getRow(rowIdx); var field = this.fields._nameMaps[colIdx+".idx"]; this.store.setValue(row.__dojo_data_item, field, value); // we don't need to call DatumChange, an eventing store will tell // us about the row change events }else{ // we can't write back, so just go ahead and change our local copy // of the data this.notify("DatumChange", arguments); } }, insertion: function(/* index */){ this.notify("Insertion", arguments); this.notify("Change", arguments); }, removal: function(/* keys */){ this.notify("Removal", arguments); this.notify("Change", arguments); }, remove: function(inRowIndexes){ // summary: // Function to remove a set of items from the store based on the row index. // inRowIndexes: // An array of row indexes from the grid to remove from the store. /* Call delete on the store */ for(var i=inRowIndexes.length-1; i>=0; i--){ // Need to find the item, then remove each from the data store var item = this.data[inRowIndexes[i]].__dojo_data_item; this._currentlyProcessing.push(item); this.store.deleteItem(item); } /* Remove from internal data structure and the view */ this._removeItems(inRowIndexes); this._currentlyProcessing = []; }, _removeItems: function(inRowIndexes /*array*/){ // summary: // Function to remove a set of items from the store based on the row index. // inRowIndexes: // An array of row indexes from the grid to remove from the store. dojox.grid.data.Dynamic.prototype.remove.apply(this, arguments); // Rebuild _rowIdentities this._rowIdentities = {}; for (var i = 0; i < this.data.length; i++){ this._setRowId(this.data[i].__dojo_data_item, 0, i); } }, canSort: function(){ // Q: Return true and re-issue the queries? // A: Return true only. Re-issue the query in 'sort'. // Note, above are original comments :) return true;";s:7:"summary";s:0:"";}s:29:"dojox.grid.data.DojoData.sort";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:8:"colIndex";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:233:" var col = Math.abs(colIndex) - 1; this.sortFields = [{'attribute': this.fields.values[col].name, 'descending': (colIndex>0)}]; // Since we're relying on the data store to sort, we have to refresh our data. this.refresh();";s:7:"summary";s:0:"";}s:32:"dojox.grid.data.DojoData.refresh";a:4:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:6:"source";s:45:" this.clearData(true); this.requestRows();";s:7:"summary";s:83:"Function to cause the model to re-query the store and rebuild the current viewport.";}s:34:"dojox.grid.data.DojoData.clearData";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"keepStore";a:1:{s:4:"type";s:7:"boolean";}}s:6:"source";s:135:" this._rowIdentities = {}; this.pages = []; this.bop = this.eop = -1; this.count = 0; this.setData((keepStore?this.store:[]));";s:7:"summary";s:0:"";}s:37:"dojox.grid.data.DojoData.processError";a:5:{s:9:"prototype";s:24:"dojox.grid.data.DojoData";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:5:"error";a:2:{s:4:"type";s:3:"The";s:7:"summary";s:59:"error object returned by the store when a problem occurred.";}s:7:"request";a:2:{s:4:"type";s:3:"The";s:7:"summary";s:37:"request object that caused the error.";}}s:6:"source";s:21:" console.log(error);";s:7:"summary";s:149:"Hook function to trap error messages from the store and emit them. Intended for connecting to and handling the error object or at least reporting it.";}s:35:"dojox.grid.data.DojoData.query.name";a:1:{s:7:"summary";s:0:"";}s:29:"dojox.grid.data.DojoData.data";a:2:{s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"summary";s:0:"";}s:30:"dojox.grid.data.DojoData.count";a:2:{s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"summary";s:0:"";}s:41:"dojox.grid.data.DojoData.fields._nameMaps";a:3:{s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"private";b:1;s:7:"summary";s:0:"";}s:36:"dojox.grid.data.DojoData._disableNew";a:3:{s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"private";b:1;s:7:"summary";s:0:"";}s:30:"dojox.grid.data.DojoData.pages";a:2:{s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"summary";s:0:"";}s:28:"dojox.grid.data.DojoData.bop";a:2:{s:8:"instance";s:24:"dojox.grid.data.DojoData";s:7:"summary";s:0:"";}s:4:"this";a:2:{s:6:"mixins";a:1:{s:6:"normal";a:1:{i:0;s:4:"args";}}s:7:"summary";s:0:"";}s:21:"dojox.grid.data.table";a:1:{s:7:"summary";s:0:"";}s:23:"dojox.grid.data.dynamic";a:1:{s:7:"summary";s:0:"";}s:29:"dojox.grid.compat._data.model";a:3:{s:4:"type";s:6:"Object";s:14:"private_parent";b:1;s:7:"summary";s:0:"";}s:23:"dojox.grid.compat._data";a:3:{s:4:"type";s:6:"Object";s:7:"private";b:1;s:7:"summary";s:0:"";}s:17:"dojox.grid.compat";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}s:10:"dojox.grid";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}s:5:"dojox";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}}