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

Multiple insert and Indent

Hi,
I am in need to perform the following operation.
When not selecting any row in the Gantt I need, when pressing the Add Record Toolbar button to insert 2 records, a parent and a child.
I am trying to use the various events and interact with javascript, but I am not able to set a parent item manually to the second record I am adding.
Could you provide a sample that shows me how I can do this operation.

       Thanks in advance

     Andrea Perazzolo

1 Reply

MK Mahalakshmi Karthikeyan Syncfusion Team November 12, 2015 12:49 PM UTC

Hi Andrea,
We can insert 2 items while pressing toolbar add record button while we haven`t select any record, one as parent and one as child to the same task with the help of "ActionComplete" click side event. Please refer the following code example for details.

@(Html.EJ().Gantt("Gantt").

ClientSideEvents(cl=>

       {

           cl.ActionComplete("actioncomplete");

       }).

//...

)


@(Html.EJ().ScriptManager())

  <script type="text/javascript">

      function actioncomplete(args){

          if (args.requestType == "save") {

              var obj = $("#Gantt").data("ejGantt");

              if (obj.model.selectedRowIndex == 0) {

                  var record = $.extend({},args.addedRecord.item);

                  obj.addRecord(record, "child");

              }

          }

      }

  </script>

You can also indent and outdent any task to make then child as well parent task using toolbar indent and outdent buttons. Please refer the following screen shot for details.

We have also prepared a sample based on this and you can find the sample under the following location.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/GanttSample-566317427
Regards,
Mahalakshmi K.

Loader.
Up arrow icon