Hello,
I am working with Gantt component. Let's assume there are y values belonging to x values. There's actually a third-level hierarchy. When I select the first parent, all x values and their corresponding y values are selected. However, when I select only the x values, their corresponding y values are not highlighted. Although they are selected in the background, they do not appear highlighted in the interface. This results in a poor user experience, as users cannot tell if the y values are selected, which may cause them to not receive the expected output from their actions.
In the link provided below, I can see a similar feature implemented with a grid component, but I want to achieve this with the Gantt component. When a user selects one of the x values, all corresponding y values should be selected. For example, after the user selects all y values, they might want to deselect one of them. I want to ensure this functionality is provided.
-> https://stackblitz.com/edit/react-uyjgxh-n4jkae?file=index.js
for example:
scenario 1: when I select node 1, then all 2 and 3 values I mean X and Y values are selected. Its correct (Screenshoot 1).
scenario 2: when i select one of 2 values, then y values belongs to the x are checked. Its also correct (Screenshot 2).
Screenshoot 1:
Screenshoot 2:
Lets contunie with my issue: 1 scenario works properly on my application but second scenario doesnt work as i expected. I choose one of x value but y values are not highlighted.
Thank you.
Hi Fatma,
Greetings from Syncfusion.
To achieve the requirement in Gantt chart, We suggest to use the "Created" event and setting the "showCheckBox" property to "true" in the column of the Gantt chart. Inside the event, we enabled the treeGrid autoCheckHierarchy property. Now, After checking in the parent, all children are also checked. Then, unchecking the parent will also uncheck the children. We have attached a code snippet and a sample for reference.
Code-Snippet:
const columns = [ { field: 'custom', showCheckbox: true, width: 80, }, ]; const created = (args) => { var treeGridInstance = document.getElementById('treeGridEditing').ej2_instances[0]; treeGridInstance.autoCheckHierarchy = true; }; |
Sample - Yr5nx4 (forked) - StackBlitz
Demo - Tree Grid · Checkbox Selection · Syncfusion React UI Components
Documentation - Check box selection in React Grid component | Syncfusion
Regards,
Sridharan
Hi Sridharan,
I find your examples good, it is absolutely what I mentioned but I really tried hard to implement those codes but I couldnt achieve. Maybe its related what i use in my codes. The difference is actually I use class component and Typescript. And I can not use easily the code below.
when i iplement those codes in my project by using class component and typescript, I can not see what i expected on UI. What should I do?
Thanks,
Fatma
We have reviewed your inquiry and developed a sample using TypeScript and a class component. Below, you will find the sample and a code snippet demonstrating how to utilize the created event.
|
Code Snippet : private created = (args: any) => { const treeGridInstance = (document.getElementById('treeGridEditing') as any).ej2_instances[0]; treeGridInstance.autoCheckHierarchy = true; };
<GanttComponent created={this.created} > |
Sample Link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/react_class-226776362
Regards,
Udhayakumar
Hi,
I still got this error. Why did I get this error I dont know and I dont understand.
What was wrong with it?
Thanks
This is my gantt below:
Hi, my react version is:
Fatma,
We were able to replicate the issue. The cause is a mismatch between the IDs used when creating treeGridInstance. We have now attached the modified code snippets, which you can use for any IDs in your application.
Code-Snippet:
private created = (args: any) => {
const treeGridInstance = (document.getElementById('treeGrid'+this.gantObj.element.id) as any).ej2_instances[0];
treeGridInstance.autoCheckHierarchy = true;
}; |
Modified Sample - https://www.syncfusion.com/downloads/support/directtrac/general/ze/reactTsx-1660126785.zip
Regards,
Sridharan
Hi again,
The code above, doesn't do what I want. I think the problem is about columns and Columns directive component use. Can you send me a code with Columns Directive component. Here It's my columns list. I also changed
but it doesn't do what I want.
Thanks
Emrah,
We were able to replicate the issue when using type: "checkbox" and showCheckbox: true in the same column. Therefore, we suggest using only showCheckbox: true for your checkbox column to achieve the actual requirement. Refer the modified code snippet for your reference.
Code-Snippet:
{ field: 'custom', showCheckbox: true, width: 80, //type:"checkbox", }, |
Modified Sample - https://www.syncfusion.com/downloads/support/directtrac/general/ze/checkBoxReactTSX_1273508408.zip
If we misunderstood, please elaborate do you want to use both type: checkbox and showCheckbox functionalities or you need to achieve only autoHierarchical checkbox selection in your application.
Regards,
Sridharan
Hi, Sridharan
I copy paste your code to my vscode and It doesn't work for me but it works on your stackblitz render page. The codes I paste:
and you can see the video below.
Emrah,
Thanks for sharing the details. For your query, we have tried to replicate the issue at our end but unable to reproduce it. We have prepared sample with your shared code snippets but the sample working fine as expected. So, share us the below requested details.
Modified Sample - https://www.syncfusion.com/downloads/support/directtrac/general/ze/checkBoxLast-306131040
Video - https://www.syncfusion.com/downloads/support/directtrac/general/ze/checkBoxVd-214579796
Regards,
Sridharan