Fixed selection and getSelected() function; controllers and selection managers are now hirachical

This commit is contained in:
Andreas Stöckel
2012-03-30 14:20:11 +00:00
parent 4cdc5f39c1
commit f50b880c19
7 changed files with 117 additions and 26 deletions

View File

@ -54,10 +54,11 @@ var et2_dataview_controller = Class.extend({
* @param _actionObjectManager is the object that manages the action
* objects.
*/
init: function (_grid, _dataProvider, _rowCallback, _linkCallback, _context,
_actionObjectManager)
init: function (_parentController, _grid, _dataProvider, _rowCallback,
_linkCallback, _context, _actionObjectManager)
{
// Copy the given arguments
this._parentController = _parentController;
this._grid = _grid;
this._dataProvider = _dataProvider;
this._rowCallback = _rowCallback;
@ -79,9 +80,14 @@ var et2_dataview_controller = Class.extend({
this._grid.setDataCallback(this._gridCallback, this);
// Create the selection manager
this._selectionMgr = new et2_dataview_selectionManager(this._indexMap,
_actionObjectManager, this._selectionFetchRange,
this._makeIndexVisible, this);
this._selectionMgr = new et2_dataview_selectionManager(
this._parentController ? this._parentController._selectionMgr : null,
this._indexMap,
_actionObjectManager,
this._selectionFetchRange,
this._makeIndexVisible,
this
);
},
destroy: function () {
@ -92,7 +98,6 @@ var et2_dataview_controller = Class.extend({
// Clear the selection timeout
this._clearTimer();
this._super();
},
/**
@ -161,6 +166,19 @@ var et2_dataview_controller = Class.extend({
}
},
/**
* Returns the depth of the controller instance.
*/
getDepth: function () {
if (this._parentController)
{
return this._parentController.getDepth() + 1;
}
return 0;
},
/* -- PRIVATE FUNCTIONS -- */
@ -442,7 +460,6 @@ var et2_dataview_controller = Class.extend({
this.entry.row.clear();
// Fill the row DOM Node with data
var tr = this.entry.row.getDOMNode();
this.self._rowCallback.call(
this.self._context,
_data,
@ -451,6 +468,15 @@ var et2_dataview_controller = Class.extend({
this.entry
);
// Attach the "subgrid" tag to the row, if the depth of this
// controller is larger than zero
var tr = this.entry.row.getDOMNode();
var d = this.self.getDepth();
if (d > 0)
{
$j(tr).addClass("subentry level_" + d);
}
var links = null;
// Get the action links if the links callback is set