We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Hide ou Change Position of a Column

Hi,

I need to show only the columns "Task Name" and "End Date" in Tree Grid.

It´s possible to hide some columns or change order of position?
ID, TaskName, End Date, Start Date, ...

Regards

Henrique


4 Replies

JR John Rajaram Syncfusion Team April 1, 2015 09:54 AM UTC

Hi Marcelo,

Thanks for using Syncfusion products.

Query 1:

I need to show only the columns "Task Name" and "End Date" in Tree Grid.

It´s possible to hide some columns.

Solution:

In Gantt control, we can display the "Task Name" and "End Date" columns alone at TreeGrid part using the “Load” client side event.

Please refer the below code snippets for more details.

Code snippet:

<body>

<form id="form1" runat="server"

<ej:Gantt ID="Gantt" runat="server"


//...


Load="Load">


//...


</ej:Gantt>


<script>

function Load(args) {

var columns = this.getColumns(),

length = columns.length;

for (var i = (length-1); i >= 0 ; i--) {

if (columns[i].field == "taskId" || columns[i].field == "startDate" || columns[i].field == "status") {

columns.splice(i, 1);

}

}

}


</script>

</form>

</body>



We have also prepared a sample based on this. Please find the sample in the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/118683/TwoColumnGantt375453174.zip

We would also like to let you know that, we have already logged and implemented the feature “Column chooser” for hiding and displaying some columns at TreeGrid part of Gantt chart dynamically.

A support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents


Query 2:

change order of position?

ID, TaskName, End Date, Start Date, ...

Solution:

In Gantt control, we can change the order position of the TreeGrid columns. Please refer the below code snippets for positioning the “End Date” column before the “Start Date” column.

Code snippet:

<body>

<form id="form1" runat="server"

<ej:Gantt ID="Gantt" runat="server"


//...


Load="Load">


//...


</ej:Gantt>


<script>

function Load(args) {

var columns = this.getColumns(),

length = columns.length;

for (var i = 0; i < length; i++) {

if (columns[i].field == "endDate") {

var endDateColumn = columns.splice(i, 1);

break;

}

}

for (var i = 0; i < length; i++) {

if (columns[i].field == "startDate") {

columns.splice(i, 0, endDateColumn[0]);

break;

}

}

}

</script>

</form>

</body>


We have also prepared a sample based on this. Please find the sample in the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/118683/ColumnOrderChange-325323468.zip

Please let us know if you require further assistance on this.
Regards,
John R



HE Henrique April 1, 2015 10:24 AM UTC

Simply amazing!!!!

Thank you very much!!

Hugs


JR John Rajaram Syncfusion Team April 2, 2015 04:30 AM UTC

Hi Marcelo,

Thanks for the update.

Please let us know if you require further assistance on this.
Regards,
John R



JR John Rajaram Syncfusion Team April 2, 2015 04:30 AM UTC

Hi Marcelo,

Thanks for the update.

Please let us know if you require further assistance on this.
Regards,
John R


Loader.
Up arrow icon