Request new features or modifications


Post by vadim_g »

Hi guys,

It's good to see that there is namedItems, similar to ExtJs actions. The only difference between them is that actions are passed through parent to child items on every level, while in B is just on 1 level. So there are 2 solutions for this:

A. Use on child namedItems: 'up.namedItems', so the 2 level child can re-use the configuration, see uncommented lines:

describe('Container namedItems', function () {
    it('', () => {
        new Container({
            appendTo: document.body,
            width: 800,
            height: 500,
            namedItems: {
                removeRow : {
                    text : 'Remove row',
                    onItem() {
                        console.log('Remove row: onItem');
                    },
                    onClick() {
                        console.log('Remove row: onClick');
                    }
                }
            },
            items: [
                {
                    type: 'toolbar',
                    //namedItems: 'up.namedItems',
                    items: {
                        removeRow: true,
                        menuButton: {
                            type: 'button',
                            text: 'Menu',
                            menu: {
                                //namedItems: 'up.namedItems',
                                items: {
                                    removeRow: true,
                                }
                            }
                        }
                    }
                }
            ],
        });
    });
});

B. Do an override on Container:

import Container from '@bryntum/grid/source/lib/Core/widget/Container';
import Override from '@bryntum/grid/source/lib/Core/mixin/Override';

class ContainerOverride {
    static get target() {
        return {
            class: Container,
        };
    }

// Override and import it in case there will be lots of namedItems: 'up.namedItems',
processItemsObject(items, namedItems, newItems) {
    if (!namedItems) {
        const parent = this.up((widget) => {
            return !! widget.namedItems;
        });
        if (parent) {
            namedItems = parent.namedItems;
        }
    }

    this._overridden.processItemsObject.call(this, items, namedItems, newItems);
}
}

Override.apply(ContainerOverride);

Wondering if would make sense to add this feature by default in the toolkit. ? As a real world example would be that there's a Grid that has a toolbar and a context menu, and we need to share the configs for some buttons btween them, as example there's Edit button in both toolbar and context menu. And in combination with widget inheritance and abstraction this ends up well designed. For example in a child class (a grid) if we need to re-org a bit the buttons we just have 2 configs (now, in our current Ext App):

	contextMenuItems: ['@addCM', '@addMultiple', '@edit', '@delete'],
	toolbarItems: ['@add', '@addMultiple', '@edit', '@delete'],

And lastly wondering why there's no onClick on menu item, or onAction, so we don't declare for each namedItems both handlers....would be good to have at least for both widgets onAction

Thanks,
Vadim


Post by marcio »

Hey Vadim,

Thanks for the detailed suggestion and for using our products! :D

I created a ticket to discuss/implement that, please follow for updates https://github.com/bryntum/support/issues/8266

Best regards,
Márcio


Post by vadim_g »

Hi guys,

wanted to let you know that "namedItems: 'up.namedItems'", is not working on feature, we are looking now for an override.

	features: {
				cellEdit: false,
				rowCopyPaste: false,
				cellMenu: {
					namedItems: 'up.namedItems',
					menu: {
						items: {
							addButton: true,
							editButton: true,
							deleteButton: true,
						},
					},
				},
			},

Vadim


Post by joakim.l »

Hi!

That's right, namedItems is available on a Container or any subclass thereof. Not available on a feature class.

Regards
Joakim


Post by Animal »

This will be fixed by this ticket: https://github.com/bryntum/support/issues/8303

namedItems is inherited from owning Widgets. It is not a configuration of Features.

See the other forum thread from your colleague.


Post Reply