Our state of the art Gantt chart
Hi,
how to acces gantt over onclick
here is code where i'm getting error for parent.please provide solution
{
type: 'container',
items: [
{
ref: 'previousButton',
html: (
<ButtonGroup variant="outlined" aria-label="Basic button group" color="inherit">
<Button onclick={(props: any) => {
const gantt = props.source.parent.parent.parent;
gantt.shiftNext();
}}>
<ChevronLeft />
</Button>
<Button>
<ChevronRight />
</Button>
</ButtonGroup>
)}]
Thanks!!
how to access gantt using custom button.
please give updated vesrion of below code accessing gantt on click
{
type: 'container',
items: [
{
ref: 'previousButton',
html: (
<ButtonGroup variant="outlined" aria-label="Basic button group" color="inherit">
<Button onclick={(props: any) => {
const gantt = props.source.parent.parent.parent;
gantt.shiftNext();
}}>
<ChevronLeft />
</Button>
<Button>
<ChevronRight />
</Button>
</ButtonGroup>
)}]
Thanks!!
Hey,
As Tasmin already mentioned and as you can see in the docs, you need to use React refs for accessing the Gantt in the button that you mentioned. The snippet that you provided doesn't clarify how you are setting your Gantt instance, so I'm sharing a general approach that you could use to access the Gantt.
const ganttRef = useRef(null);
const ganttConfig = {
// ...other configs
tbar: {
type: 'container',
items: [
{
ref: 'previousButton',
html: (
<ButtonGroup variant="outlined" aria-label="Basic button group" color="inherit">
<Button onclick={(props: any) => {
const gantt = ganttRef.current.instance;
gantt.shiftNext();
}}>
<ChevronLeft />
</Button>
<Button>
<ChevronRight />
</Button>
</ButtonGroup>
)}]}
}
return <BryntumGantt
ref = {ganttRef}
{...ganttConfig}
/>