Premium support for our pure JavaScript UI components


Post by marcio »

Hey,

You should return a DomConfig object, and to render correctly in this case (matching the button structure), you should have something like this:

class CustomButton extends Button {
    static get type() {
        return "custom-button"
    }

compose() {
    if (this.metadata?.status === "Template") {
        return {
            style: "display: none"
        };
    } else if (this.metadata?.status != null) {
        const text = this.metadata?.status === "Draft" ? "Mark Live" : "Mark Draft";
        return {
            tag: 'button',
            children: [
                { 
                    tag: 'label',
                    text,
                }
            ]
        }
    }
    
}
}

Best regards,
Márcio


Post by dominicdolan »

Okay thanks,

That seems to be working a bit better.

I just have one more issue. Is there any way of getting a reference to the Gantt instance from the compose method now. Before I was able to get it through the parent hierarchy like: this.parent.parent.gantt or whatever. Now that the button is in a popup menu there doesn't seem to be any obvious way of doing this?

Thanks,
Dominic


Post by tasnim »

Here is how you can get the gantt instance

this.up('gantt');

Or like this:

this.parent.owner

Post by dominicdolan »

Okay thanks. It's working perfectly now


Post Reply