From 82fa5839513966f94820debae3505dc0e7c076c7 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 4 Aug 2014 09:39:44 +0000 Subject: [PATCH] svn commit -m 'Backport commit 47925 committed by NathanGray. Handle num_rows set by application: - Don\'t overwrite num_rows setting if the application sets it for some reason - If num_rows is 0, don\'t get the initial rows server side - If num_rows is 0 and the initial rows are missing, trigger an update right away to get them asyncronously.' etemplate --- .../inc/class.etemplate_widget_nextmatch.inc.php | 11 +++++++++-- etemplate/js/et2_extension_nextmatch.js | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php index b217ab1a3d..316ab7007a 100644 --- a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php +++ b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php @@ -113,7 +113,11 @@ class etemplate_widget_nextmatch extends etemplate_widget $value = self::get_array(self::$request->content, $form_name, true); $value['start'] = 0; - $value['num_rows'] = self::INITIAL_ROWS; + if(!array_key_exists('num_rows',$value)) + { + $value['num_rows'] = self::INITIAL_ROWS; + } + $value['rows'] = array(); $send_value = $value; @@ -159,7 +163,10 @@ class etemplate_widget_nextmatch extends etemplate_widget $send_value['order'] = $send_value['sort']['id']; $send_value['sort'] = $send_value['sort']['asc'] ? 'ASC' : 'DESC'; } - $total = self::call_get_rows($send_value, $send_value['rows'], self::$request->readonlys); + if($value['num_rows'] != 0) + { + $total = self::call_get_rows($send_value, $send_value['rows'], self::$request->readonlys); + } $value =& self::get_array(self::$request->content, $form_name, true); // Add favorite here so app doesn't save it in the session diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index c4e2daac5c..4c165b30b0 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -1082,7 +1082,7 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], this.dataview.grid.setTotalCount(total); // Insert any data sent from server, so invalidate finds data already - if(this.options.settings.rows) + if(this.options.settings.rows && this.options.settings.num_rows) { this.controller.loadInitialData( this.options.settings.dataStorePrefix, @@ -1510,6 +1510,13 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], // Set filters to current values this.controller.setFilters(this.activeFilters); + // If no data was sent from the server, and num_rows is 0, the nm will be empty. + // This triggers a cache check. + if(!(this.options.settings.rows && this.options.settings.num_rows)) + { + this.controller.update(); + } + // Load the default sort order if (this.options.settings.order && this.options.settings.sort) {