
sap.ui.define([
"sap/ui/table/TreeTable",
"sap/base/Log"
], function (TreeTable, Log) {
"use strict";
var CustomTreeTable = TreeTable.extend("custom.control.controller.TreeTable", {
renderer: function (oRm, oControl) {
TreeTable.getMetadata().getRenderer().render(oRm, oControl);
},
metadata: {
properties: {
/**
* Key used to access personalization data.
*/
persistencyKey: {
type: "string",
group: "Misc",
defaultValue: ""
}
}
}
});
/**
* Registration of a callback function. The provided callback function is executed
* when saving a variant is triggered and must provide all relevant fields and values in JSON.
* @public
* @param {function} fCallBack Called when a variant must be fetched
* @returns {sap.ui.table.TreeTable} Reference to this in order to allow method chaining.
*/
CustomTreeTable.prototype.registerFetchData = function (fCallBack) {
this._fRegisteredFetchData = fCallBack;
return this;
};
/**
* Registration of a callback function. The provided callback function is executed
* when a variant must be applied.
* The callback function will receive the corresponding data set containing all relevant data in JSON,
* as initially provided by the callback for fetchData.
* @public
* @param {function} fCallBack Called when a variant must be applied
* @returns {sap.ui.table.TreeTable} Reference to this in order to allow method chaining.
*/
CustomTreeTable.prototype.registerApplyData = function (fCallBack) {
this._fRegisteredApplyData = fCallBack;
return this;
};
/**
* Creates and returns the variant representation.
* @returns {object} JSON object
* @public
*/
CustomTreeTable.prototype.fetchVariant = function () {
if (this._fRegisteredFetchData) {
try {
return this._fRegisteredFetchData();
} catch (ex) {
Log.error("callback for fetching data throws an exception");
}
} else {
Log.warning("no callback for fetch data supplied");
}
return {};
};
/**
* Triggers the registered callBack for applying the variant data.
* @private
* @param {object} oVariant the data blob representing part of the variant content
* @returns {object} data to be stored as part of the variant content
*/
CustomTreeTable.prototype.applyVariant = function (oVariant) {
if (this._fRegisteredApplyData) {
try {
return this._fRegisteredApplyData(oVariant);
} catch (ex) {
Log.error("callback for applying data throws an exception");
}
} else {
Log.warning("no callback for appy data supplied");
}
return null;
};
return CustomTreeTable;
});
var oPersInfo = new PersonalizableInfo({
keyName: "id",
type: "table"
});
oPersInfo.setControl(this._oTable);
this._oSmartVariantManagement.addPersonalizableControl(oPersInfo);
this._oSmartVariantManagement.initialise(function () {
this._oSmartVariantManagement.currentVariantSetModified(false);
}.bind(this), this._oTable);
this._oTable.registerFetchData(this.onTableFetchData.bind(this));
this._oTable.registerApplyData(this.onTableApplyData.bind(this));
onTableFetchData: function () { … }
onTableApplyData: function (oVariantContent) { … }
this._oSmartVariantManagement.currentVariantSetModified(true);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |