mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-02 15:29:58 +00:00
object grid: allow one to declaratively specify rows
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>
This commit is contained in:
parent
f0f898d2dd
commit
bc9ae6029f
@ -19,6 +19,11 @@ Useful for a readonly tabular display
|
|||||||
Ext.define('Proxmox.grid.ObjectGrid', {
|
Ext.define('Proxmox.grid.ObjectGrid', {
|
||||||
extend: 'Ext.grid.GridPanel',
|
extend: 'Ext.grid.GridPanel',
|
||||||
alias: ['widget.proxmoxObjectGrid'],
|
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,
|
disabled: false,
|
||||||
hideHeaders: true,
|
hideHeaders: true,
|
||||||
|
|
||||||
@ -246,6 +251,17 @@ Ext.define('Proxmox.grid.ObjectGrid', {
|
|||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
let me = this;
|
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;
|
let rows = me.rows;
|
||||||
|
|
||||||
if (!me.rstore) {
|
if (!me.rstore) {
|
||||||
|
Loading…
Reference in New Issue
Block a user