Problems about Gantt Chart Edit function

Hi,

Can you help about the issues & questions about editing in Gantt:

1 - After editing a task, if I try to reload original data (by a button click) application falls to exception when rerendering toolbar. Exception message:

    fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
    Unhandled exception in circuit 'AypZjSt2EJ5fhloVpRMdT502y3VEniBRgEIg7kxQvbQ'.
    System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
    at System.Collections.Generic.List`1.get_Item(Int32 index)
    at System.Linq.Enumerable.ElementAt[TSource](IEnumerable`1 source, Int32 index)
    at Syncfusion.Blazor.Gantt.Internal.ToolbarRenderer`1.RefreshToolbarItems()
    at Syncfusion.Blazor.Gantt.Internal.ToolbarRenderer`1.OnParametersSetAsync()
    at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)


2 - I was able to disable editing on condition at version 19.4.0.56 like below. Currently this is not working. In particular Edit button is displayed when user clicks on a row. I don't want to display Edit button on specific conditions. Example code:


3 - I want to change the "Edit task" tooltip of Edit button but could not find any property to set. I believe it is set internally. Is there a way to change this tooltip?

An example project is attached.
Thanks & Best regards


Attachment: BlazorSvrSfGantt_71aa895.rar


8 Replies 1 reply marked as answer

MS Monisha Sivanthilingam Syncfusion Team May 6, 2022 12:07 PM UTC

Hi Yunus,


Greetings from Syncfusion support.


Please find the response for your queries below.


Sl.No.

Query

Syncfusion Comments

 

1

After editing a task, if I try to reload original data (by a button click) application falls to exception when rerendering toolbar. Exception message:

Yes, we were able to replicate the issue you reported. We have logged a bug report for it. You can track its status from the below feedback link.

 

Feedback: https://www.syncfusion.com/feedback/34698/script-error-thrown-when-dynamically-assigning-the-data-to-the-gantt

 

The fix will be provided in the patch release scheduled for May 25, 2022

 

2

I was able to disable editing on condition at version 19.4.0.56 like below. Currently this is not working. In particular Edit button is displayed when user clicks on a row. I don't want to display Edit button on specific conditions. Example code:

We can resolve this issue in the sample level itself. Please add the below code in your application to resolve this issue.

 

Index.cshtml

 

public void OnGanttRowSelect(RowSelectEventArgs<TaskData> args)

{

  if (args.Data.TaskName.Contains("Project"))

  {

     _gantt.EditSettings = new GanttEditSettings() { AllowEditing = false };

  }

  else

  {

     _gantt.EditSettings = new GanttEditSettings() { AllowEditing = true };

  }

}

 

 

 

3

I want to change the "Edit task" tooltip of Edit button but could not find any property to set. I believe it is set internally. Is there a way to change this tooltip?

We can use a simple work-around to achieve this requirement. We have surrounded the Gantt Chart with a SFTooltip component. We have used the OnRender event to set the content of the tooltip when hovering over the edit item. The below code snippets demonstrate the solution.

 

Index.razor

 

<SfTooltip ID="Tooltip" Target=".e-toolbar-item" OnRender="OnTooltipRender" Content="@Content">

     <SfGantt @ref="Gantt" DataSource="@TaskCollection" Height="450px" Width="900px" DateFormat="dd/MM/yyyy" Toolbar="@(new List<string>() { "Edit" })">

 

                  …

 

     </SfGantt>

</SfTooltip>

 

@code{

    public string Content { get; set; }

    public void OnTooltipRender(TooltipEventArgs args)

    {

        if(args.Target.ID == "sfGantt_2_edit")

        {

            Content = "Edit";

        }

    }

}

 

 

 


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorSvrSfGantt-668957920


Regards,

Monisha.



YU Yunus May 16, 2022 09:25 AM UTC

Hi Monisha,

Thank you and sorry for late answer.

1 - Thanks for the feedback link, I'll be waiting for the update.

2 - I tried the solution and it is working pretty well, thank you.

3 - I tried the solution and it is feasible to change the popup with this approach, thanks. 
However when used together with my 2nd question (displaying Edit button on condition), the application throws below exception when moving mouse over the buttons one after another. When Edit button is not displayed, there is no problem, but when Edit button is displayed then application breaks.


[12:18:47 WRN] Unhandled exception rendering component: TypeError: Cannot read properties of null (reading 'removeChild')
System.InvalidOperationException: TypeError: Cannot read properties of null (reading 'removeChild')
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InvokeRenderCompletedCallsAfterUpdateDisplayTask(Task updateDisplayTask, Int32[] updatedComponents)
[12:18:47 ERR] Unhandled exception in circuit 'fPltLa6zHfiSzH5eqmac8GD-aKVL4RRUDVLjYQHATgw'.
System.AggregateException: One or more errors occurred. (TypeError: Cannot read properties of null (reading 'removeChild'))
---> System.InvalidOperationException: TypeError: Cannot read properties of null (reading 'removeChild')
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InvokeRenderCompletedCallsAfterUpdateDisplayTask(Task updateDisplayTask, Int32[] updatedComponents)
--- End of inner exception stack trace ---

Can you check this please?

Thanks and kind regards



MS Monisha Sivanthilingam Syncfusion Team May 17, 2022 11:54 AM UTC

Hi Yunus,


We were unable to replicate the issue you reported. We also checked with the edit button and without the edit button. If possible, please share an issue reproducible sample or modify the below attached sample to replicate the issue.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/1748381112805426


Regards,

Monisha.



YU Yunus May 21, 2022 12:37 PM UTC

Hi Monisha,

I could not create the same effect on sample project. 
I used a workaround based on your solution and solved my issue.
Thank you very much



MS Monisha Sivanthilingam Syncfusion Team May 23, 2022 05:24 AM UTC

Hi Yunus,


You are welcome.


We are glad that you were able to resolve the issue yourself.


Please contact us if you require any further assistance.


Regards,

Monisha.



MS Monisha Sivanthilingam Syncfusion Team May 26, 2022 12:29 PM UTC

Hi Yunus,


Thank you for your patience.


The reported issue “Script error thrown when dynamically assigning the data to the gantt” has been fixed in version v20.1.57. Please find the release notes from the below link.


Release Notes: https://blazor.syncfusion.com/documentation/release-notes/20.1.57?type=all#gantt-chart


We would like to inform you that one of your original queries was to be able to disable editing for a task conditionally. We would like to share an alternative and better work-around for it. We have made use of the OnActionBegin and OnCellEdit events to achieve your requirements. The below code snippets demonstrate the solution.


Index.razor

 

public void OnActionBegin(GanttActionEventArgs<TaskData> args)

{

  if ((args.RequestType == Syncfusion.Blazor.Gantt.Action.BeforeOpenEditDialog) && (args.RowData.TaskName.Contains("Project")))

  {

    args.Cancel = true;

  }

}

 

public void OnCellEdit(CellEditArgs<TaskData> args)

{

  if(args.RowData.TaskName.Contains("Project"))

  {

    args.Cancel = true;

  }

}

 


We recommend not using the previously shared work-around, as it may cause issues in taskbar editing. However, if you still insist on using the previous work-around we shared for this query, we would like to add a few changes to it. They are as below:


Index.razor

 

public void OnGanttRowSelect(RowSelectEventArgs<TaskData> args)

{

  if (args.Data.TaskName.Contains("Project"))

  {

    _gantt.EditSettings = new GanttEditSettings() { AllowEditing = false, AllowTaskbarEditing = true };

  }

  else

  {

    _gantt.EditSettings = new GanttEditSettings() { AllowEditing = true, AllowTaskbarEditing= true };

  }

}

 


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/174838~1995482630


Regards,

Monisha.


Marked as answer

YU Yunus June 1, 2022 01:49 PM UTC

Hi Monisha,

Thank you for the updates and sample code. They are working fine.


Best regards



MS Monisha Sivanthilingam Syncfusion Team June 2, 2022 06:55 AM UTC

Hi Yunus,


You are welcome.


Please contact us if you require any further assistance.


Regards,

Monisha.


Loader.
Up arrow icon