SfGantt - Customize new task dialog

Hi there,

using AllowEditing="falsewe can costomize the edit dialog to hide all input fields we don't want to be edited:



But we cannot hide these fields for a new task, they are greyed out and disabled but are still visible:



Any idea to customize the new task dialog?

Cheers,
Volker



5 Replies 1 reply marked as answer

PP Pooja Priya Krishna Moorthy Syncfusion Team September 17, 2020 10:29 AM UTC

Hi Volker, 
We can limit the number of fields to be displayed in add dialog by using GanttAddDialogFields property.  Also we would like to suggest you to use GanttEditDialogFields property, to define the fields to be displayed in edit dialog. 
Please find the below code example. 
 
<SfGantt TValue="TaskData" ID="Gantt" )"> 
    //... 
   <GanttAddDialogFields> 
        <GanttAddDialogField Type="DialogFieldType.General" Fields="@(new string[] { "TaskId" ,"TaskName"})"></GanttAddDialogField> 
    </GanttAddDialogFields> 
  <GanttEditDialogFields> 
        <GanttEditDialogField Type="DialogFieldType.General" Fields="@(new string[] { "TaskId" ,"TaskName"})"></GanttEditDialogField> 
    </GanttEditDialogFields> 
</SfGantt> 

In the provided sample, we display only id and name field. 
 
Regards, 
Pooja K. 


Marked as answer

VO Volker September 17, 2020 11:49 AM UTC

Hi Pooja,

works wonderfully, thank you very much!

Cheers from Graz/Austria,
Volker


PP Pooja Priya Krishna Moorthy Syncfusion Team September 17, 2020 12:25 PM UTC

Hi Volker,
Most welcome.
Please get back to us if you have any other queries.

Regards,
Pooja K.


JO John November 7, 2022 10:43 AM UTC

Does anyone know how to add a drop down to the add/edit dialogs? I would like my users to have a list of predefined tasks to choose from when adding a new task.


I would also like to automatically set the parentID. I imagine i can do this by checking the parent of the rowselected and passing it as a parameter, but how?


Thanks

John




MS Monisha Sivanthilingam Syncfusion Team November 9, 2022 11:50 AM UTC

Hi John,


Please find the response for your queries below.


Sl.No.

 

Query

Syncfusion Comments

1

How do I add a drop down to the add/edit dialogs? I need to limit my users to a list of predefined values to choose from when adding a new task.

We have support for edit template in the Blazor Gantt Chart. We can use this support to render a drop down list in the Ad/Edit dialog. The below code snippets demonstrate the solution.

 

Index.razor

 

<GanttColumn Field="TaskName">

   <EditTemplate>

      @{

         var task = (context as TaskData);

      }

      <SfDropDownList @ref="dropdown" Placeholder="Name" FloatLabelType="Syncfusion.Blazor.Inputs.FloatLabelType.Always"

         ID="TaskName" Value="task.TaskName" TItem="string" TValue="string" DataSource="@DropDownData">

      </SfDropDownList>

   </EditTemplate>

</GanttColumn>

 

<GanttEvents OnActionBegin="ActionBeginHandler" TValue="TaskData"></GanttEvents>

 

@code{

   public void ActionBeginHandler(GanttActionEventArgs<TaskData> args)

   {

     if (args.RequestType.Equals(Syncfusion.Blazor.Gantt.Action.BeforeSave) ||

         args.RequestType.Equals(Syncfusion.Blazor.Gantt.Action.BeforeAdd))

     {

        var data = args.Data as TaskData;

        data.TaskName = dropdown.Value.ToString();

     }

   }

}

 

Online Documentation: https://blazor.syncfusion.com/documentation/gantt-chart/managing-tasks#cell-edit-template

 

2

I would also like to automatically set the parentID. I imagine i can do this by checking the parent of the rowselected and passing it as a parameter, but how?

We can use the NewRowPosition property to automatically set the parentId of the new record. If we can set that property to Child, then the newly added record will be added as the child of the selected record.

 

Index.razor

 

<GanttEditSettings AllowAdding="true" AllowEditing=true AllowTaskbarEditing=true

     NewRowPosition="Syncfusion.Blazor.Gantt.RowPosition.Child"></GanttEditSettings>

 

 

 


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


Regards,

Monisha.


Loader.
Up arrow icon