Our pure JavaScript Scheduler component


Post by Jerome Cauchon »

Hi,
i'm trying to get the current eventRecord in the onClick handler of my bbar tool. How can get it in my handler. See attached project.

Thanks

const EventTooltipTemplate = ({eventRecord}: {eventRecord: EventModel}): ReactElement => {
        return (
            <>
                <Grid container spacing={1}>
                    <Grid item md={6}>
                        <Typography variant="h5">
                            {eventRecord.name}
                        </Typography>
                    </Grid>
                </Grid>
            </>
        );
    };
    
.... eventTooltipFeature: { allowOver: true, bbar: [ { text: 'test', icon: 'b-fa b-fa-fw b-fa-eye', onClick: () => { // how to get eventRecord?? }, }, ], template: ({ eventRecord }: { eventRecord: EventModel }) => ReactDOMServer.renderToString(<EventTooltipTemplate eventRecord={eventRecord} />), }, ....
Attachments
basic_copy 2.zip
(3.29 MiB) Downloaded 55 times

Post by saki »

Arrow functions do not have this. The following will work:

                    onClick: function() {
                        // @ts-ignore
                        console.log(`name=`, this.up('tooltip').eventRecord.name);
                    }

You can also utilize https://bryntum.com/docs/scheduler/#Scheduler/feature/EventTooltip#config-tools It is demonstrated here: https://bryntum.com/examples/scheduler/tooltips/

Note: Shortcut would be:

                    onClick() {
                        // @ts-ignore
                        console.log(`name=`, this.up('tooltip').eventRecord.name);
                    }

Post by Jerome Cauchon »

Thanks Saki!


Post Reply