So that users of this component do not necesacrrily need to add an
initComponent override and make the `me.add_XYZ_row()` there, but
instead can use something like:
gridRows: [
{
xtype: 'text',
name: 'http-proxy',
text: gettext('HTTP proxy'),
defaultValue: Proxmox.Utils.noneText,
vtype: 'HttpProxy',
deleteEmpty: true,
},
],
I avoid using `rows` as config key as that is internally used for
quite a few things, and potentially some existing users (did not
checked all). We can still switch to that easily if it is deemed to
be better...
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Ext.define('Proxmox.grid.ObjectGrid', {
extend: 'Ext.grid.GridPanel',
alias: ['widget.proxmoxObjectGrid'],
+
+ // can be used as declarative replacement over manually calling the add_XYZ_row helpers,
+ // see top-level doc-comment above for details/example
+ gridRows: [],
+
disabled: false,
hideHeaders: true,
initComponent: function() {
let me = this;
+ for (const rowdef of me.gridRows || []) {
+ let addFn = me[`add_${rowdef.xtype}_row`];
+ if (typeof addFn !== 'function') {
+ throw `unknown object-grid row xtype '${rowdef.xtype}'`;
+ } else if (typeof rowdef.name !== 'string') {
+ throw `object-grid row need a valid name string-property!`;
+ } else {
+ addFn.call(me, rowdef.name, rowdef.text || rowdef.name, rowdef);
+ }
+ }
+
let rows = me.rows;
if (!me.rstore) {