From a8ed2af93832783cf99ee43ad9b35842e413d049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= <andreas.stoeckel@googlemail.com> Date: Fri, 30 Mar 2012 12:00:59 +0000 Subject: [PATCH] Added subgrid support to nm --- etemplate/js/et2_extension_nextmatch.js | 23 +++++++++++++++++++ .../js/et2_extension_nextmatch_controller.js | 10 +++++++- .../js/et2_extension_nextmatch_rowProvider.js | 13 ++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index a45647c81c..ed574ae205 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -548,6 +548,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, { this.egw(), this.getInstanceManager().etemplate_exec_id, "nm", + null, this.dataview.grid, this.rowProvider, this.options.settings.action_links, @@ -580,6 +581,28 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, { } }, + _getSubgrid: function (_row, _parentId) { + // Create a new grid with the row as parent and the dataview grid as + // parent grid + var grid = new et2_dataview_grid(_row, this.dataview.grid); + + // Create a new controller for the grid + var controller = new et2_nextmatch_controller( + this.egw(), + this.getInstanceManager().etemplate_exec_id, + "nm", + _parentId, + grid, + this.rowProvider, + this.options.settings.action_links, + null, + this.options.settings.actions + ); + controller.update(); + + return grid; + }, + _getInitialOrder: function (_rows, _rowId) { var _order = []; diff --git a/etemplate/js/et2_extension_nextmatch_controller.js b/etemplate/js/et2_extension_nextmatch_controller.js index 97d315e7f7..7dd0ec6923 100644 --- a/etemplate/js/et2_extension_nextmatch_controller.js +++ b/etemplate/js/et2_extension_nextmatch_controller.js @@ -43,7 +43,7 @@ var et2_nextmatch_controller = et2_dataview_controller.extend( * @param _actions contains the actions, may be null if an object manager * is given. */ - init: function (_egw, _execId, _widgetId, _grid, _rowProvider, + init: function (_egw, _execId, _widgetId, _parentId, _grid, _rowProvider, _actionLinks, _objectManager, _actions) { // Copy the egw reference @@ -68,6 +68,7 @@ var et2_nextmatch_controller = et2_dataview_controller.extend( this._actionLinks = _actionLinks this._execId = _execId; this._widgetId = _widgetId; + this._parentId = _parentId; this._rowProvider = _rowProvider; // We start with no filters @@ -179,6 +180,13 @@ var et2_nextmatch_controller = et2_dataview_controller.extend( dataFetch: function (_queriedRange, _callback, _context) { + + // Merge the parent id into the _queriedRange if it is set + if (this._parentId !== null) + { + _queriedRange["parent_id"] = _queriedRange; + } + // Pass the fetch call to the API, multiplex the data about the // nextmatch instance into the call. this.egw.dataFetch( diff --git a/etemplate/js/et2_extension_nextmatch_rowProvider.js b/etemplate/js/et2_extension_nextmatch_rowProvider.js index 3f3c977ac3..ec4e1484d4 100644 --- a/etemplate/js/et2_extension_nextmatch_rowProvider.js +++ b/etemplate/js/et2_extension_nextmatch_rowProvider.js @@ -27,9 +27,11 @@ var et2_nextmatch_rowProvider = Class.extend({ /** * Creates the nextmatch row provider. */ - init: function (_rowProvider) { + init: function (_rowProvider, _subgridCallback, _context) { // Copy the arguments this._rowProvider = _rowProvider; + this._subgridCallback = _subgridCallback; + this._context = _context; }, /** @@ -160,6 +162,15 @@ var et2_nextmatch_rowProvider = Class.extend({ var tr = _row.getDOMNode(); tr.appendChild(row); + // Make the row expandable + if (typeof _data["is_parent"] !== "undefined" && _data["is_parent"]) + { + _row.makeExpandable(true, function () { + return this._subgridCallback.call(this._context, + _row, _data["parent_id"]); + }, this); + } + // Set the row data this._setRowData(this._template.rowData, tr, mgrs);