diff --git a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php index 8254f1b68d..9872dd2755 100644 --- a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php +++ b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php @@ -96,7 +96,7 @@ class etemplate_widget_nextmatch extends etemplate_widget /** * Number of rows to send initially */ - const INITIAL_ROWS = 25; + const INITIAL_ROWS = 50; /** * Set up what we know on the server side. diff --git a/etemplate/js/et2_dataview_controller.js b/etemplate/js/et2_dataview_controller.js index f5eb7670fd..c4ef3b8b9b 100644 --- a/etemplate/js/et2_dataview_controller.js +++ b/etemplate/js/et2_dataview_controller.js @@ -184,6 +184,34 @@ var et2_dataview_controller = Class.extend({ } }, + /** + * Load initial data + * + * @param {string} uid_key Name of the unique row identifier field + * @param {Object} data Key / Value mapping of initial data. + */ + loadInitialData: function (uid_prefix, uid_key, data) { + var idx = 0; + for(var key in data) + { + // Skip any extra keys + if(typeof data[key] != "object" || data[key] == null || typeof data[key][uid_key] == "undefined") continue; + + // Add to row / uid map + var entry = this._getIndexEntry(idx++); + entry.uid = data[key][uid_key]; + if(entry.uid.indexOf(uid_prefix) < 0) + { + entry.uid = uid_prefix + "::" + entry.uid; + } + + // Add to data cache so grid will find it + egw.dataStoreUID(entry.uid, data[key]) + + // Don't try to insert the rows, grid will do that automatically + } + }, + /** * Returns the depth of the controller instance. */ diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 84551b6947..1fb26e07cd 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -889,6 +889,7 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], null, this.options.actions ); + // Need to trigger empty row the first time if(total == 0) this.controller._emptyRow(); @@ -910,6 +911,24 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], this.options.settings.total : 0; // This triggers an invalidate, which updates the grid this.dataview.grid.setTotalCount(total); + + // Insert any data sent from server, so invalidate finds data already + if(this.options.settings.rows) + { + var prefix = this.options.settings.dataStorePrefix; + if(!prefix) + { + prefix = this.options.settings.get_rows.split('.'); + prefix = prefix[0]; + } + this.controller.loadInitialData( + prefix, + this.options.settings.row_id, + this.options.settings.rows + ); + // Remove, to prevent duplication + delete this.options.settings.rows; + } }, _parseGrid: function(_grid) {