10898 : I want to click/doubleclick on an empty spot in the chart to create a new item in Gantt_ASP.

Question

I’m currently evaluating the GTP.WEB component to visualize a online booking application. I’ve had no problem binding data and viewing it in the Gantt chart, but now I want to click/doubleclick on an empty spot in the chart to create a new item. So my question is what is the easiest way of accomplishing this? Which events should/could be used and how do I pass along the information about where in the chart I clicked?

Answer

Download the latest release 3.0.5.10 and you will have a new event on the Gantt_ASP called:

Gantt_ASP1.OnGanttRow_ClientClick

You can implement that with code looking more or less like this:

  void Gantt_ASP1_OnGanttRow_ClientClick(Gantt_ASP aGantt, GanttRowClickEventArgs e)
  {
    if (aGantt.MouseButton_ClientSide == 1 && e.ThisClickSelectedLink==null)
    {
        DataRow dr=dataSet1.Tables[“timeitem”].NewRow();
        dr[“owner”]=(e.Row.GridNode.ListItemWhenDataBound() as DataRowView)[“id”];
        dr[“start”]=aGantt.Gantt.DateScaler.PixelToTime(e.X);
        dr[“stop”]=aGantt.Gantt.DateScaler.PixelToTime(e.X).AddDays(2);
        dataSet1.Tables[“timeitem”].Rows.Add(dr);
    }
    LabelClickInfo.Text=”You clicked GanttRow with id “+((e.Row.GridNode.ListItemWhenDataBound() as DataRowView)[“id”]).ToString();
  }

This is the code currently running in the sample found here: http://www.plexityhide.nu/