Added subgrid support to nm

This commit is contained in:
Andreas Stöckel 2012-03-30 12:00:59 +00:00
parent 1d405d05ba
commit a8ed2af938
3 changed files with 44 additions and 2 deletions

View File

@ -548,6 +548,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
this.egw(), this.egw(),
this.getInstanceManager().etemplate_exec_id, this.getInstanceManager().etemplate_exec_id,
"nm", "nm",
null,
this.dataview.grid, this.dataview.grid,
this.rowProvider, this.rowProvider,
this.options.settings.action_links, 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) { _getInitialOrder: function (_rows, _rowId) {
var _order = []; var _order = [];

View File

@ -43,7 +43,7 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
* @param _actions contains the actions, may be null if an object manager * @param _actions contains the actions, may be null if an object manager
* is given. * is given.
*/ */
init: function (_egw, _execId, _widgetId, _grid, _rowProvider, init: function (_egw, _execId, _widgetId, _parentId, _grid, _rowProvider,
_actionLinks, _objectManager, _actions) { _actionLinks, _objectManager, _actions) {
// Copy the egw reference // Copy the egw reference
@ -68,6 +68,7 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
this._actionLinks = _actionLinks this._actionLinks = _actionLinks
this._execId = _execId; this._execId = _execId;
this._widgetId = _widgetId; this._widgetId = _widgetId;
this._parentId = _parentId;
this._rowProvider = _rowProvider; this._rowProvider = _rowProvider;
// We start with no filters // We start with no filters
@ -179,6 +180,13 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
dataFetch: function (_queriedRange, _callback, _context) { 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 // Pass the fetch call to the API, multiplex the data about the
// nextmatch instance into the call. // nextmatch instance into the call.
this.egw.dataFetch( this.egw.dataFetch(

View File

@ -27,9 +27,11 @@ var et2_nextmatch_rowProvider = Class.extend({
/** /**
* Creates the nextmatch row provider. * Creates the nextmatch row provider.
*/ */
init: function (_rowProvider) { init: function (_rowProvider, _subgridCallback, _context) {
// Copy the arguments // Copy the arguments
this._rowProvider = _rowProvider; this._rowProvider = _rowProvider;
this._subgridCallback = _subgridCallback;
this._context = _context;
}, },
/** /**
@ -160,6 +162,15 @@ var et2_nextmatch_rowProvider = Class.extend({
var tr = _row.getDOMNode(); var tr = _row.getDOMNode();
tr.appendChild(row); 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 // Set the row data
this._setRowData(this._template.rowData, tr, mgrs); this._setRowData(this._template.rowData, tr, mgrs);