From 629d040927228aca103487aa9d8b910baf261c0a Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Wed, 29 Jun 2011 07:32:42 +0000 Subject: [PATCH] Roo.data.Store @config multisort - enables multiple sort columns, based on the order of the columns - remote only support --- Roo/data/Store.js | 17 ++- Roo/grid/Grid.js | 4 +- Roo/grid/GridView.js | 81 ++++++++++-- Roo/grid/HeaderDropZone.js | 1 + examples/grid/edit-grid.js | 262 +++++++++++++++++++------------------ roojs-all.js | 21 +-- roojs-debug.js | 101 ++++++++++++-- roojs-ui-debug.js | 101 ++++++++++++-- roojs-ui.js | 21 +-- 9 files changed, 422 insertions(+), 187 deletions(-) diff --git a/Roo/data/Store.js b/Roo/data/Store.js index af4eb59a67..8f300a6844 100644 --- a/Roo/data/Store.js +++ b/Roo/data/Store.js @@ -38,7 +38,8 @@ Roo.data.Store = function(config){ "start" : "start", "limit" : "limit", "sort" : "sort", - "dir" : "dir" + "dir" : "dir", + "multisort" : "_multisort" }; if(config && config.data){ @@ -150,6 +151,7 @@ Roo.data.Store = function(config){ this.relayEvents(this.proxy, ["loadexception"]); } this.sortToggle = {}; + this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled. Roo.data.Store.superclass.constructor.call(this); @@ -182,6 +184,10 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"} */ /** + * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present) + */ + multiSort: false, + /** * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false). */ @@ -338,6 +344,11 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { p[pn["sort"]] = this.sortInfo.field; p[pn["dir"]] = this.sortInfo.direction; } + if (this.multiSort) { + var pn = this.paramNames; + p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder }); + } + this.proxy.load(p, this.reader, this.loadRecords, this, options); } }, @@ -476,7 +487,9 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { sort : function(fieldName, dir){ var f = this.fields.get(fieldName); if(!dir){ - if(this.sortInfo && this.sortInfo.field == f.name){ // toggle sort dir + this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir; + + if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC"); }else{ dir = f.sortDir; diff --git a/Roo/grid/Grid.js b/Roo/grid/Grid.js index ee77dcfb67..8bb46974c8 100644 --- a/Roo/grid/Grid.js +++ b/Roo/grid/Grid.js @@ -77,7 +77,7 @@ Roo.grid.Grid = function(container, config){ this.dataSource= Roo.factory(this.dataSource, Roo.data); this.ds = this.dataSource; this.ds.xmodule = this.xmodule || false; - + } @@ -418,6 +418,8 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { */ dropTarget: false, + + // private rendered : false, diff --git a/Roo/grid/GridView.js b/Roo/grid/GridView.js index 42617f458b..0e6f208d45 100644 --- a/Roo/grid/GridView.js +++ b/Roo/grid/GridView.js @@ -1013,6 +1013,26 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { if(this.enableMoveAnim && Roo.enableFx){ this.fly(this.getHeaderCell(colIndex).firstChild).highlight(this.hlColor); } + // if multisort - fix sortOrder, and reload.. + if (this.grid.dataSource.multiSort) { + // the we can call sort again.. + var dm = this.grid.dataSource; + var cm = this.grid.colModel; + var so = []; + for(var i = 0; i < cm.config.length; i++ ) { + + if ((typeof(dm.sortToggle[cm.config[i].dataIndex]) == 'undefined')) { + continue; // dont' bother, it's not in sort list or being set. + } + + so.push(cm.config[i].dataIndex); + }; + dm.sortOrder = so; + dm.load(dm.lastOptions); + + + } + }, updateCell : function(dm, rowIndex, dataIndex){ @@ -1159,20 +1179,43 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { }, updateHeaderSortState : function(){ - var state = this.ds.getSortState(); - if(!state){ - return; - } - this.sortState = state; - var sortColumn = this.cm.findColumnIndex(state.field); - if(sortColumn != -1){ - var sortDir = state.direction; - var sc = this.sortClasses; - var hds = this.el.select(this.headerSelector).removeClass(sc); - hds.item(sortColumn).addClass(sc[sortDir == "DESC" ? 1 : 0]); + + // sort state can be single { field: xxx, direction : yyy} + // or { xxx=>ASC , yyy : DESC ..... } + + var mstate = {}; + if (!this.ds.multiSort) { + var state = this.ds.getSortState(); + if(!state){ + return; + } + mstate[state.field] = state.direction; + // FIXME... - this is not used here.. but might be elsewhere.. + this.sortState = state; + + } else { + mstate = this.ds.sortToggle; + } + //remove existing sort classes.. + + var sc = this.sortClasses; + var hds = this.el.select(this.headerSelector).removeClass(sc); + + for(var f in mstate) { + + var sortColumn = this.cm.findColumnIndex(f); + + if(sortColumn != -1){ + var sortDir = mstate[f]; + hds.item(sortColumn).addClass(sc[sortDir == "DESC" ? 1 : 0]); + } } + + + }, + handleHeaderClick : function(g, index){ if(this.headersDisabled){ return; @@ -1182,6 +1225,22 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { return; } g.stopEditing(); + + if (dm.multiSort) { + // update the sortOrder + var so = []; + for(var i = 0; i < cm.config.length; i++ ) { + + if ((typeof(dm.sortToggle[cm.config[i].dataIndex]) == 'undefined') && (index != i)) { + continue; // dont' bother, it's not in sort list or being set. + } + + so.push(cm.config[i].dataIndex); + }; + dm.sortOrder = so; + } + + dm.sort(cm.getDataIndex(index)); }, diff --git a/Roo/grid/HeaderDropZone.js b/Roo/grid/HeaderDropZone.js index 12b1028d0d..3bc5694bda 100644 --- a/Roo/grid/HeaderDropZone.js +++ b/Roo/grid/HeaderDropZone.js @@ -39,6 +39,7 @@ Roo.extend(Roo.grid.HeaderDropZone, Roo.dd.DropZone, { if(cindex !== false){ return this.view.getHeaderCell(cindex); } + return null; }, nextVisible : function(h){ diff --git a/examples/grid/edit-grid.js b/examples/grid/edit-grid.js index 46a4a75622..36e3812bfb 100644 --- a/examples/grid/edit-grid.js +++ b/examples/grid/edit-grid.js @@ -10,133 +10,137 @@ */ Roo.BLANK_IMAGE_URL = "../../images/default/s.gif"; - -Roo.onReady(function(){ - Roo.QuickTips.init(); - function formatBoolean(value){ - return value ? 'Yes' : 'No'; - }; - - function formatDate(value){ - return value ? value.dateFormat('M d, Y') : ''; - }; - // shorthand alias - var fm = Roo.form, Ed = Roo.grid.GridEditor; - - // the column model has information about grid columns - // dataIndex maps the column to the specific data field in - // the data store (created below) - var cm = new Roo.grid.ColumnModel([{ - header: "Common Name", - dataIndex: 'common', - width: 220, - editor: new Ed(new fm.TextField({ - allowBlank: false - })) - },{ - header: "Light", - dataIndex: 'light', - width: 130, - editor: new Ed(new Roo.form.ComboBox({ - typeAhead: true, - triggerAction: 'all', - transform:'light', - lazyRender:true - })) - },{ - header: "Price", - dataIndex: 'price', - width: 70, - align: 'right', - renderer: 'usMoney', - editor: new Ed(new fm.NumberField({ - allowBlank: false, - allowNegative: false, - maxValue: 10 - })) - },{ - header: "Available", - dataIndex: 'availDate', - width: 95, - renderer: formatDate, - editor: new Ed(new fm.DateField({ - format: 'm/d/y', - minValue: '01/01/06', - disabledDays: [0, 6], - disabledDaysText: 'Plants are not available on the weekends' - })) - },{ - header: "Indoor?", - dataIndex: 'indoor', - width: 55, - renderer: formatBoolean, - editor: new Ed(new fm.Checkbox()) - }]); - - // by default columns are sortable - cm.defaultSortable = true; - - // this could be inline, but we want to define the Plant record - // type so we can add records dynamically - var Plant = Roo.data.Record.create([ - // the "name" below matches the tag name to read, except "availDate" - // which is mapped to the tag "availability" - {name: 'common', type: 'string'}, - {name: 'botanical', type: 'string'}, - {name: 'light'}, - {name: 'price', type: 'float'}, // automatic date conversions - {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'}, - {name: 'indoor', type: 'bool'} - ]); - - // create the Data Store - var ds = new Roo.data.Store({ - // load using HTTP - proxy: new Roo.data.HttpProxy({url: 'plants.xml'}), - - // the return will be XML, so lets set up a reader - reader: new Roo.data.XmlReader({ - // records will have a "plant" tag - record: 'plant' - }, Plant) - }); - - // create the editor grid - var grid = new Roo.grid.EditorGrid('editor-grid', { - ds: ds, - cm: cm, - enableColLock:false - }); - - var layout = Roo.BorderLayout.create({ - center: { - margins:{left:3,top:3,right:3,bottom:3}, - panels: [new Roo.GridPanel(grid)] - } - }, 'grid-panel'); - - - // render it - grid.render(); - - - var gridHead = grid.getView().getHeaderPanel(true); - var tb = new Roo.Toolbar(gridHead, [{ - text: 'Add Plant', - handler : function(){ - var p = new Plant({ - common: 'New Plant 1', - light: 'Mostly Shade', - price: 0, - availDate: new Date(), - indoor: false - }); - grid.stopEditing(); - ds.insert(0, p); - grid.startEditing(0, 0); - } - }]); - - // trigger the data store load - ds.load(); + +var grid = false; + +Roo.onReady(function(){ + Roo.QuickTips.init(); + function formatBoolean(value){ + return value ? 'Yes' : 'No'; + }; + + function formatDate(value){ + return value ? value.dateFormat('M d, Y') : ''; + }; + // shorthand alias + var fm = Roo.form, Ed = Roo.grid.GridEditor; + + // the column model has information about grid columns + // dataIndex maps the column to the specific data field in + // the data store (created below) + var cm = new Roo.grid.ColumnModel([{ + header: "Common Name", + dataIndex: 'common', + width: 220, + editor: new Ed(new fm.TextField({ + allowBlank: false + })) + },{ + header: "Light", + dataIndex: 'light', + width: 130, + editor: new Ed(new Roo.form.ComboBox({ + typeAhead: true, + triggerAction: 'all', + transform:'light', + lazyRender:true + })) + },{ + header: "Price", + dataIndex: 'price', + width: 70, + align: 'right', + renderer: 'usMoney', + editor: new Ed(new fm.NumberField({ + allowBlank: false, + allowNegative: false, + maxValue: 10 + })) + },{ + header: "Available", + dataIndex: 'availDate', + width: 95, + renderer: formatDate, + editor: new Ed(new fm.DateField({ + format: 'm/d/y', + minValue: '01/01/06', + disabledDays: [0, 6], + disabledDaysText: 'Plants are not available on the weekends' + })) + },{ + header: "Indoor?", + dataIndex: 'indoor', + width: 55, + renderer: formatBoolean, + editor: new Ed(new fm.Checkbox()) + }]); + + // by default columns are sortable + cm.defaultSortable = true; + + // this could be inline, but we want to define the Plant record + // type so we can add records dynamically + var Plant = Roo.data.Record.create([ + // the "name" below matches the tag name to read, except "availDate" + // which is mapped to the tag "availability" + {name: 'common', type: 'string'}, + {name: 'botanical', type: 'string'}, + {name: 'light'}, + {name: 'price', type: 'float'}, // automatic date conversions + {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'}, + {name: 'indoor', type: 'bool'} + ]); + + // create the Data Store + var ds = new Roo.data.Store({ + // load using HTTP + proxy: new Roo.data.HttpProxy({url: 'plants.xml'}), + remoteSort : true, + + // the return will be XML, so lets set up a reader + reader: new Roo.data.XmlReader({ + // records will have a "plant" tag + record: 'plant' + }, Plant) + }); + + // create the editor grid + grid = new Roo.grid.EditorGrid('editor-grid', { + ds: ds, + cm: cm, + enableColLock:false, + multiSort : true + }); + + var layout = Roo.BorderLayout.create({ + center: { + margins:{left:3,top:3,right:3,bottom:3}, + panels: [new Roo.GridPanel(grid)] + } + }, 'grid-panel'); + + + // render it + grid.render(); + + + var gridHead = grid.getView().getHeaderPanel(true); + var tb = new Roo.Toolbar(gridHead, [{ + text: 'Add Plant', + handler : function(){ + var p = new Plant({ + common: 'New Plant 1', + light: 'Mostly Shade', + price: 0, + availDate: new Date(), + indoor: false + }); + grid.stopEditing(); + ds.insert(0, p); + grid.startEditing(0, 0); + } + }]); + + // trigger the data store load + ds.load(); }); \ No newline at end of file diff --git a/roojs-all.js b/roojs-all.js index c61e7726be..b98ada17b4 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -305,16 +305,16 @@ f.getField=function(B){return p.fields.get(B);};return f;};Roo.data.Record.AUTO_ this.dirty=true;if(!this.modified){this.modified={};}if(typeof this.modified[A]=='undefined'){this.modified[A]=this.data[A];} this.data[A]=B;if(!this.editing){this.store.afterEdit(this);}},get:function(A){return this.data[A];},beginEdit:function(){this.editing=true;this.modified={};},cancelEdit:function(){this.editing=false;delete this.modified;},endEdit:function(){this.editing=false;if(this.dirty&&this.store){this.store.afterEdit(this);}},reject:function(){var m=this.modified;for(var n in m){if(typeof m[n]!="function"){this.data[n]=m[n];}} this.dirty=false;delete this.modified;this.editing=false;if(this.store){this.store.afterReject(this);}},commit:function(){this.dirty=false;delete this.modified;this.editing=false;if(this.store){this.store.afterCommit(this);}},hasError:function(){return this.error!=null;},clearError:function(){this.error=null;},copy:function(A){return new this.constructor(Roo.apply({},this.data),A||this.id);}}; -Roo.data.Store=function(A){this.data=new Roo.util.MixedCollection(false);this.data.getKey=function(o){return o.id;};this.baseParams={};this.paramNames={"start":"start","limit":"limit","sort":"sort","dir":"dir"};if(A&&A.data){this.inlineData=A.data;delete A.data;} +Roo.data.Store=function(A){this.data=new Roo.util.MixedCollection(false);this.data.getKey=function(o){return o.id;};this.baseParams={};this.paramNames={"start":"start","limit":"limit","sort":"sort","dir":"dir","multisort":"_multisort"};if(A&&A.data){this.inlineData=A.data;delete A.data;} Roo.apply(this,A);if(this.reader){this.reader=Roo.factory(this.reader,Roo.data);this.reader.xmodule=this.xmodule||false;if(!this.recordType){this.recordType=this.reader.recordType;}if(this.reader.onMetaChange){this.reader.onMetaChange=this.onMetaChange.createDelegate(this);}}if(this.recordType){this.fields=this.recordType.prototype.fields;} this.modified=[];this.addEvents({datachanged:true,metachange:true,add:true,remove:true,update:true,clear:true,beforeload:true,load:true,loadexception:true});if(this.proxy){this.proxy=Roo.factory(this.proxy,Roo.data);this.proxy.xmodule=this.xmodule||false;this.relayEvents(this.proxy,["loadexception"]);} -this.sortToggle={};Roo.data.Store.superclass.constructor.call(this);if(this.inlineData){this.loadData(this.inlineData);delete this.inlineData;}};Roo.extend(Roo.data.Store,Roo.util.Observable,{remoteSort:false,pruneModifiedRecords:false,lastOptions:null,add:function(A){A=[].concat(A);for(var i=0,B=A.length;iv2?1:(v1v2?1:(v1ASC , yyy : DESC ..... } + + var mstate = {}; + if (!this.ds.multiSort) { + var state = this.ds.getSortState(); + if(!state){ + return; + } + mstate[state.field] = state.direction; + // FIXME... - this is not used here.. but might be elsewhere.. + this.sortState = state; + + } else { + mstate = this.ds.sortToggle; } - this.sortState = state; - var sortColumn = this.cm.findColumnIndex(state.field); - if(sortColumn != -1){ - var sortDir = state.direction; - var sc = this.sortClasses; - var hds = this.el.select(this.headerSelector).removeClass(sc); - hds.item(sortColumn).addClass(sc[sortDir == "DESC" ? 1 : 0]); + //remove existing sort classes.. + + var sc = this.sortClasses; + var hds = this.el.select(this.headerSelector).removeClass(sc); + + for(var f in mstate) { + + var sortColumn = this.cm.findColumnIndex(f); + + if(sortColumn != -1){ + var sortDir = mstate[f]; + hds.item(sortColumn).addClass(sc[sortDir == "DESC" ? 1 : 0]); + } } + + + }, + handleHeaderClick : function(g, index){ if(this.headersDisabled){ return; @@ -48563,6 +48622,22 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { return; } g.stopEditing(); + + if (dm.multiSort) { + // update the sortOrder + var so = []; + for(var i = 0; i < cm.config.length; i++ ) { + + if ((typeof(dm.sortToggle[cm.config[i].dataIndex]) == 'undefined') && (index != i)) { + continue; // dont' bother, it's not in sort list or being set. + } + + so.push(cm.config[i].dataIndex); + }; + dm.sortOrder = so; + } + + dm.sort(cm.getDataIndex(index)); }, diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 574e69da8e..4f54ee726a 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -4720,7 +4720,8 @@ Roo.data.Store = function(config){ "start" : "start", "limit" : "limit", "sort" : "sort", - "dir" : "dir" + "dir" : "dir", + "multisort" : "_multisort" }; if(config && config.data){ @@ -4832,6 +4833,7 @@ Roo.data.Store = function(config){ this.relayEvents(this.proxy, ["loadexception"]); } this.sortToggle = {}; + this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled. Roo.data.Store.superclass.constructor.call(this); @@ -4864,6 +4866,10 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"} */ /** + * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present) + */ + multiSort: false, + /** * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false). */ @@ -5020,6 +5026,11 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { p[pn["sort"]] = this.sortInfo.field; p[pn["dir"]] = this.sortInfo.direction; } + if (this.multiSort) { + var pn = this.paramNames; + p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder }); + } + this.proxy.load(p, this.reader, this.loadRecords, this, options); } }, @@ -5158,7 +5169,9 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { sort : function(fieldName, dir){ var f = this.fields.get(fieldName); if(!dir){ - if(this.sortInfo && this.sortInfo.field == f.name){ // toggle sort dir + this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir; + + if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC"); }else{ dir = f.sortDir; @@ -32015,7 +32028,7 @@ Roo.grid.Grid = function(container, config){ this.dataSource= Roo.factory(this.dataSource, Roo.data); this.ds = this.dataSource; this.ds.xmodule = this.xmodule || false; - + } @@ -32356,6 +32369,8 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { */ dropTarget: false, + + // private rendered : false, @@ -32818,6 +32833,7 @@ Roo.extend(Roo.grid.HeaderDropZone, Roo.dd.DropZone, { if(cindex !== false){ return this.view.getHeaderCell(cindex); } + return null; }, nextVisible : function(h){ @@ -33949,6 +33965,26 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { if(this.enableMoveAnim && Roo.enableFx){ this.fly(this.getHeaderCell(colIndex).firstChild).highlight(this.hlColor); } + // if multisort - fix sortOrder, and reload.. + if (this.grid.dataSource.multiSort) { + // the we can call sort again.. + var dm = this.grid.dataSource; + var cm = this.grid.colModel; + var so = []; + for(var i = 0; i < cm.config.length; i++ ) { + + if ((typeof(dm.sortToggle[cm.config[i].dataIndex]) == 'undefined')) { + continue; // dont' bother, it's not in sort list or being set. + } + + so.push(cm.config[i].dataIndex); + }; + dm.sortOrder = so; + dm.load(dm.lastOptions); + + + } + }, updateCell : function(dm, rowIndex, dataIndex){ @@ -34095,20 +34131,43 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { }, updateHeaderSortState : function(){ - var state = this.ds.getSortState(); - if(!state){ - return; + + // sort state can be single { field: xxx, direction : yyy} + // or { xxx=>ASC , yyy : DESC ..... } + + var mstate = {}; + if (!this.ds.multiSort) { + var state = this.ds.getSortState(); + if(!state){ + return; + } + mstate[state.field] = state.direction; + // FIXME... - this is not used here.. but might be elsewhere.. + this.sortState = state; + + } else { + mstate = this.ds.sortToggle; } - this.sortState = state; - var sortColumn = this.cm.findColumnIndex(state.field); - if(sortColumn != -1){ - var sortDir = state.direction; - var sc = this.sortClasses; - var hds = this.el.select(this.headerSelector).removeClass(sc); - hds.item(sortColumn).addClass(sc[sortDir == "DESC" ? 1 : 0]); + //remove existing sort classes.. + + var sc = this.sortClasses; + var hds = this.el.select(this.headerSelector).removeClass(sc); + + for(var f in mstate) { + + var sortColumn = this.cm.findColumnIndex(f); + + if(sortColumn != -1){ + var sortDir = mstate[f]; + hds.item(sortColumn).addClass(sc[sortDir == "DESC" ? 1 : 0]); + } } + + + }, + handleHeaderClick : function(g, index){ if(this.headersDisabled){ return; @@ -34118,6 +34177,22 @@ Roo.extend(Roo.grid.GridView, Roo.grid.AbstractGridView, { return; } g.stopEditing(); + + if (dm.multiSort) { + // update the sortOrder + var so = []; + for(var i = 0; i < cm.config.length; i++ ) { + + if ((typeof(dm.sortToggle[cm.config[i].dataIndex]) == 'undefined') && (index != i)) { + continue; // dont' bother, it's not in sort list or being set. + } + + so.push(cm.config[i].dataIndex); + }; + dm.sortOrder = so; + } + + dm.sort(cm.getDataIndex(index)); }, diff --git a/roojs-ui.js b/roojs-ui.js index 0d63566661..0914083a3f 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -62,16 +62,16 @@ f.getField=function(B){return p.fields.get(B);};return f;};Roo.data.Record.AUTO_ this.dirty=true;if(!this.modified){this.modified={};}if(typeof this.modified[A]=='undefined'){this.modified[A]=this.data[A];} this.data[A]=B;if(!this.editing){this.store.afterEdit(this);}},get:function(A){return this.data[A];},beginEdit:function(){this.editing=true;this.modified={};},cancelEdit:function(){this.editing=false;delete this.modified;},endEdit:function(){this.editing=false;if(this.dirty&&this.store){this.store.afterEdit(this);}},reject:function(){var m=this.modified;for(var n in m){if(typeof m[n]!="function"){this.data[n]=m[n];}} this.dirty=false;delete this.modified;this.editing=false;if(this.store){this.store.afterReject(this);}},commit:function(){this.dirty=false;delete this.modified;this.editing=false;if(this.store){this.store.afterCommit(this);}},hasError:function(){return this.error!=null;},clearError:function(){this.error=null;},copy:function(A){return new this.constructor(Roo.apply({},this.data),A||this.id);}}; -Roo.data.Store=function(A){this.data=new Roo.util.MixedCollection(false);this.data.getKey=function(o){return o.id;};this.baseParams={};this.paramNames={"start":"start","limit":"limit","sort":"sort","dir":"dir"};if(A&&A.data){this.inlineData=A.data;delete A.data;} +Roo.data.Store=function(A){this.data=new Roo.util.MixedCollection(false);this.data.getKey=function(o){return o.id;};this.baseParams={};this.paramNames={"start":"start","limit":"limit","sort":"sort","dir":"dir","multisort":"_multisort"};if(A&&A.data){this.inlineData=A.data;delete A.data;} Roo.apply(this,A);if(this.reader){this.reader=Roo.factory(this.reader,Roo.data);this.reader.xmodule=this.xmodule||false;if(!this.recordType){this.recordType=this.reader.recordType;}if(this.reader.onMetaChange){this.reader.onMetaChange=this.onMetaChange.createDelegate(this);}}if(this.recordType){this.fields=this.recordType.prototype.fields;} this.modified=[];this.addEvents({datachanged:true,metachange:true,add:true,remove:true,update:true,clear:true,beforeload:true,load:true,loadexception:true});if(this.proxy){this.proxy=Roo.factory(this.proxy,Roo.data);this.proxy.xmodule=this.xmodule||false;this.relayEvents(this.proxy,["loadexception"]);} -this.sortToggle={};Roo.data.Store.superclass.constructor.call(this);if(this.inlineData){this.loadData(this.inlineData);delete this.inlineData;}};Roo.extend(Roo.data.Store,Roo.util.Observable,{remoteSort:false,pruneModifiedRecords:false,lastOptions:null,add:function(A){A=[].concat(A);for(var i=0,B=A.length;iv2?1:(v1v2?1:(v1