📄 bufferedstore.js
字号:
* The method assumes that there will be no data available anymore in the * underlying data store. */ removeAll : function() { this.totalLength = 0; this.data.clear(); if(this.pruneModifiedRecords){ this.modified = []; } this.fireEvent("clear", this); }, /** * Requests a range of data from the underlying data store. Similiar to the * start and limit parameter usually send to the server, the method needs * an array of ranges of indexes. * Example: To load all records at the positions 1,2,3,4,9,12,13,14, the supplied * parameter should equal to [[1,4],[9],[12,14]]. * The request will only be done if the beforeselectionsloaded events return * value does not equal to false. */ loadRanges : function(ranges) { var max_i = ranges.length; if(max_i > 0 && !this.selectionsProxy.activeRequest && this.fireEvent("beforeselectionsload", this, ranges) !== false){ var lParams = this.lastOptions.params; var params = {}; params.ranges = Ext.encode(ranges); if (lParams) { if (lParams.sort) { params.sort = lParams.sort; } if (lParams.dir) { params.dir = lParams.dir; } } var options = {}; for (var i in this.lastOptions) { options.i = this.lastOptions.i; } options.ranges = params.ranges; this.selectionsProxy.load(params, this.reader, this.selectionsLoaded, this, options); } }, /** * Alias for loadRanges. */ loadSelections : function(ranges) { this.loadRanges(ranges); }, /** * Called as a callback by the proxy which loads pending selections. * Will fire the selectionsload event with the loaded records if, and only * if the return value of the checkVersionChange event does not equal to * false. */ selectionsLoaded : function(o, options, success) { if (this.checkVersionChange(o, options, success) !== false) { this.fireEvent("selectionsload", this, o.records, Ext.decode(options.ranges)); } else { this.fireEvent("selectionsload", this, [], Ext.decode(options.ranges)); } }, /** * Checks if the version supplied in <tt>o</tt> differs from the version * property of the current instance of this object and fires the versionchange * event if it does. */ // private checkVersionChange : function(o, options, success) { if(o && success !== false){ if (o.version !== undefined) { var old = this.version; this.version = o.version; if (this.version !== old) { return this.fireEvent('versionchange', this, old, this.version); } } } }, /** * Overwrites the parent implementation to pass the boolean bufferedSort * parameter to {applySort}. * The sort procedure tries to respect the current data in the buffer. If the * found index would not be within the bufferRange, Number.MIN_VALUE is returned to * indicate that the record would be sorted below the first record in the buffer * range, while Number.MAX_VALUE would indicate that the record would be added after * the last record in the buffer range. * * The method is not guaranteed to return the relative index of the record * in the data model as returned by the underlying domain model. */ findInsertIndex : function(record) { this.suspendEvents(); // store original data var data = this.data.clone(); // check if the record would be added to/inserted before the current // buffer range if (data.getCount() >= this.bufferSize) { var first = this.data.first(); var last = this.data.last(); this.data.clear(); this.data.add(record); this.data.add(first); this.data.add(last); this.applySort(true); var index = this.data.indexOf(record); if (index == 0 || index == 2) { this.data = data; this.resumeEvents(); return index == 0 ? Number.MIN_VALUE : Number.MAX_VALUE; } } this.data = data.clone(); this.data.add(record); this.applySort(true); var index = this.data.indexOf(record); this.data = data; this.resumeEvents(); return index; }, /** * Removed snapshot check */ // private sortData : function(f, direction) { direction = direction || 'ASC'; var st = this.fields.get(f).sortType; var fn = function(r1, r2){ var v1 = st(r1.data[f]), v2 = st(r2.data[f]); return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0); }; this.data.sort(direction, fn); }, /** * Overwritten so the method can be used by findInsertIndex. Any call from * loadRecords will do nothing, since bufferedSort argument won't equal to * <tt>true</tt>. */ applySort : function(bufferedSort) { if(bufferedSort === true && this.sortInfo){ var s = this.sortInfo, f = s.field; this.sortData(f, s.direction); } }, /** * @cfg {Number} bufferSize The number of records that will at least always * be available in the store for rendering. This value will be send to the * server as the <tt>limit</tt> parameter and should not change during the * lifetime of a grid component. Note: In a paging grid, this number would * indicate the page size. * The value should be set high enough to make a userfirendly scrolling * possible and should be greater than the sum of {nearLimit} and * {visibleRows}. Usually, a value in between 150 and 200 is good enough. * A lesser value will more often make the store re-request new data, while * a larger number will make loading times higher. */ // private onMetaChange : function(meta, rtype, o) { this.version = null; Ext.ux.grid.BufferedStore.superclass.onMetaChange.call(this, meta, rtype, o); }, /** * Will fire the versionchange event if the version of incoming data has changed. */ // private loadRecords : function(o, options, success) { this.checkVersionChange(o, options, success); Ext.ux.grid.BufferedStore.superclass.loadRecords.call(this, o, options, success); }, //--------------------------------------EMPTY----------------------------------- // no interface concept, so simply overwrite and leave them empty as for now clearFilter : function(){}, isFiltered : function(){}, collect : function(){}, createFilterFn : function(){}, sum : function(){}, filter : function(){}, filterBy : function(){}, query : function(){}, queryBy : function(){}, find : function(){}, findBy : function(){} });
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -