From 39c1efc789ba2336707e86f43e8086fbdb9752e1 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 6 Nov 2013 18:55:57 +0000 Subject: [PATCH] Fix up dataview / nm filter changes. Removes extra server call to ajax_get_rows. --- etemplate/js/et2_dataview_controller.js | 22 +++++----------------- etemplate/js/et2_extension_nextmatch.js | 13 +++++++++---- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/etemplate/js/et2_dataview_controller.js b/etemplate/js/et2_dataview_controller.js index c1c0ea8a1b..1e82e3a5bb 100644 --- a/etemplate/js/et2_dataview_controller.js +++ b/etemplate/js/et2_dataview_controller.js @@ -129,9 +129,6 @@ var et2_dataview_controller = Class.extend({ * @param {boolean} clear */ update: function (clear) { - // Clear the fetch queue - this._queue = {}; - this._clearTimer(); // --------- @@ -140,20 +137,11 @@ var et2_dataview_controller = Class.extend({ if(clear) { - this._grid.clear(); + this._grid.clear.apply(this._grid,[]); } // Remove all rows which are outside the view range this._grid.cleanup(); - - // Remove all index entries which are currently not displayed - for (var key in this._indexMap) - { - if (!this._indexMap[key].row) - { - delete this._indexMap[key]; - } - } - + // --------- // Get the currently visible range from the grid @@ -772,11 +760,11 @@ var et2_dataview_controller = Class.extend({ } // Make sure _response.order.length is not longer than the requested - // count - var order = _response.order.splice(0, this.count); + // count, if a specific count was requested + var order = this.count != 0 ? _response.order.splice(0, this.count) : _response.order; // Get the current index map for the updated region - var idxMap = this.self._getIndexMapping(this.start, this.count); + var idxMap = this.self._getIndexMapping(this.start, order.length); // Update the grid using the new order. The _updateOrder function does // not update the internal mapping while inserting and deleting rows, as diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 34dcfd6472..e6dc0ffccd 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -400,6 +400,9 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], } }, this.activeFilters.col_filter, et2_INextmatchHeader); + // Explicitly the total count to zero, we're going to get some new info + this.controller._grid.setTotalCount(0); + // Trigger an update this.controller.update(true); }, @@ -864,10 +867,6 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], this.rowProvider.setDataRowTemplate(columnWidgets, _rowData, this); - // Set the initial row count - var total = typeof this.options.settings.total != "undefined" ? - this.options.settings.total : 0; - this.dataview.grid.setTotalCount(total); // Create the grid controller this.controller = new et2_nextmatch_controller( @@ -897,6 +896,12 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], ));*/ this.controller.setFilters(this.activeFilters); + + // Set the initial row count + var total = typeof this.options.settings.total != "undefined" ? + this.options.settings.total : 0; + // This triggers an invalidate, which updates the grid + this.dataview.grid.setTotalCount(total); }, _parseGrid: function(_grid) {