Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Maintain 50% Proportional Layout Between Gantt Table and Tasks on Both Small and Large Screens? #133

Closed
xkfe opened this issue Dec 9, 2024 · 1 comment

Comments

@xkfe
Copy link

xkfe commented Dec 9, 2024

Hi, I'm working with DHTMLX Gantt and I need to ensure that the Gantt chart's task area and the table (with task details) always take up 50% of the screen width, regardless of whether the screen is small or large.

Currently, the layout is responsive, but I am struggling to set a fixed proportion between the task chart and the table so that they both occupy 50% of the available screen width on all devices.

Any help or code examples would be greatly appreciated!

Thanks in advance!

@MaksimLakatkouXBPL
Copy link

Hello. You can achieve this by getting the total width of the Gantt container and assigning half of it to the grid using the grid_width property.

gantt.config.columns = [
    { name: 'text',       label: 'Task name',  tree: true, width: '*' },
    { name: 'start_date', label: 'Start time', align: 'center' },
    { name: 'duration',   label: 'Duration',   align: 'center' },
    { name: 'add',        label: '' },
];

gantt.attachEvent('onGanttRender', () => {
    const containerWidth = gantt.$root.offsetWidth;
    const tableWidth = Math.round(containerWidth / 2);
    gantt.config.grid_width = tableWidth;
});

Here’s an example: https://snippet.dhtmlx.com/z994berx

@xkfe xkfe closed this as completed Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants