2011-08-29 17:04:10 +02:00
|
|
|
/**
|
|
|
|
* eGroupWare eTemplate2 - Class which contains a factory method for rows
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage dataview
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Andreas Stöckel
|
|
|
|
* @copyright Stylite 2011
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*egw:uses
|
|
|
|
et2_dataview_interfaces;
|
|
|
|
*/
|
|
|
|
|
2011-08-31 17:39:24 +02:00
|
|
|
var et2_dataview_row = et2_dataview_container.extend(et2_dataview_IDataRow, {
|
2011-08-29 17:04:10 +02:00
|
|
|
|
2011-09-02 18:15:57 +02:00
|
|
|
init: function(_dataProvider, _rowProvider, _invalidationElem, _avgHeight) {
|
2011-08-31 17:39:24 +02:00
|
|
|
|
|
|
|
this._super(_dataProvider, _rowProvider, _invalidationElem);
|
|
|
|
|
2011-09-02 18:15:57 +02:00
|
|
|
this._avgHeight = _avgHeight;
|
2011-09-08 20:36:09 +02:00
|
|
|
this._idx = null;
|
2011-09-01 12:02:23 +02:00
|
|
|
|
2011-09-05 16:35:28 +02:00
|
|
|
this.rowWidget = null;
|
|
|
|
this.hasAvgHeight = false;
|
|
|
|
|
|
|
|
// Get the default row object and scale the row to the average height
|
2011-09-06 18:50:38 +02:00
|
|
|
this.tr = this.rowProvider.getPrototype("dataRow");
|
2011-09-05 16:35:28 +02:00
|
|
|
|
|
|
|
// Append the row
|
2011-08-31 17:39:24 +02:00
|
|
|
this.appendNode(this.tr);
|
2011-08-29 17:04:10 +02:00
|
|
|
},
|
|
|
|
|
2011-09-05 16:35:28 +02:00
|
|
|
destroy: function() {
|
|
|
|
|
|
|
|
// Unregister the row from the data provider
|
2011-09-08 20:36:09 +02:00
|
|
|
if (this._idx !== null)
|
|
|
|
{
|
|
|
|
this.dataProvider.unregisterDataRow(this._idx);
|
|
|
|
}
|
2011-09-05 16:35:28 +02:00
|
|
|
|
|
|
|
// Free the row widget first, if it has been set
|
|
|
|
if (this.rowWidget)
|
|
|
|
{
|
|
|
|
this.rowWidget.free();
|
|
|
|
}
|
|
|
|
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
|
2011-09-02 18:15:57 +02:00
|
|
|
setIdx: function(_idx) {
|
|
|
|
this._idx = _idx;
|
|
|
|
|
2011-09-05 16:35:28 +02:00
|
|
|
// Register the row in the data provider
|
|
|
|
this.dataProvider.registerDataRow(this, _idx);
|
|
|
|
|
|
|
|
// Set the default height of the rowWidget has not been immediately
|
|
|
|
// created
|
|
|
|
if (!this.rowWidget)
|
|
|
|
{
|
|
|
|
$j("td:first", this.tr).height(this._avgHeight);
|
|
|
|
this.hasAvgHeight = true;
|
|
|
|
}
|
2011-08-29 17:04:10 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
updateData: function(_data) {
|
2011-09-05 16:35:28 +02:00
|
|
|
|
|
|
|
// Reset the height
|
|
|
|
if (this.hasAvgHeight)
|
|
|
|
{
|
|
|
|
$j("td:first", this.tr).height("auto");
|
|
|
|
this.hasAvgHeight = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Free the row widget if it already existed
|
|
|
|
if (this.rowWidget != null)
|
|
|
|
{
|
|
|
|
this.rowWidget.free();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the row widget - it automatically generates the widgets and
|
|
|
|
// attaches the given data to them
|
|
|
|
this.rowWidget = this.rowProvider.getDataRow(_data, this.tr, this._idx);
|
|
|
|
|
|
|
|
// Invalidate this element
|
|
|
|
this.invalidate();
|
2011-08-29 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2011-08-31 17:39:24 +02:00
|
|
|
|