10441 : Detecting the exact datetime of a location.

Question

When I drag a timeitem and drop it into another location, am I able to detect the exact datetime (Start datetime and End Datetime) of the location where the timeitem is to be dropped? I need to get the exact date so that I could identify whether a timeitem is allowed to be placed there. Thank you.

Answer

In the OnTimeItem_Move event you get the orginal time item and you can access it’s Start and Stop. You also get the e.diff value that is the pixel value of the change. You can use the e.diff pixel value to calculate the new value.

To translate between pixel space and date time space use the Gantt.DateScaler.PixelToTime and Gantt.DateScaler.TimeToPixel functions.

If this was a move operation:
theNewValueForStart = Gantt.DateScaler.PixelToTime(e.TimeItem.DrawRect.Left+e.Diff)

 

10467 : .NET tooltip delay

Question

We’re loading the tooltip text in the gantt_OnTimeItem_Hoover event. This works fine, but the tool tip appears too quickly. How and where should I set the toolTip.InitialDelay? Every way that I tried to set this property has no effect.

Answer

I tried the sample Gantt_TimeItems and you are correct, the tooltip shows directly…

This is a bit odd since these values are set on the tooltip component:

this.toolTip1.AutomaticDelay = 2000;
this.toolTip1.AutoPopDelay = 20000;
this.toolTip1.InitialDelay = 2000;
this.toolTip1.ReshowDelay = 2000;

It appears to be some un-document feature that if you call toolTip1.SetToolTip(gantt1.TimeItemArea,newTooltipText); with the same text, the tooltip show directly; ignoring the InitialDelay etc…

Work around is to avoid setting the same text twice:

if (toolTip1.GetToolTip(gantt1.TimeItemArea)!=newTooltipText)
  toolTip1.SetToolTip(gantt1.TimeItemArea,newTooltipText);

Then it started to behave as expected (Only tested in VS2006 CLR20).

10424 : Time zones

Question

My application (a smart client) downloads data from a web service and displays it using GTP.NET. I’ve run into some difficulties regarding time zone. For example: if a business is using -7 (mountain standard time with DST) and someone connects to the web service using some other time zone setting in windows, all the times are messed up.

I was thinking about different approaches to dealing with this problem. Would it be possible to set an instance of a gantt to work off of a different time zone than the windows machine it is currently running on? The main thing I’m worried about is making daylight savings times correct in the gantt. Some users might not have their OS set to the “right” time zone for the data and it could cause a problem.

Answer

This can quickly become really nasty unless we make some clear definitions. I think i would do it this way: Store all date-data in the format of ONE defined TimeZone.

Lets say we choose UTC.

So when we get data from our DB we need to “convert” it to the User-time-zone; using the TimeZone.GetUtcOffset function will help us substract or add the correct value.

Later when we want to apply updates to the database we call the DateTime.ToUniversalTime method and store the result.

This way the user can have a setting that makes sense for him or her and we do not need to worry… If I were to use your app I would look at the Gantt in UTC+1 when planning my work at home and then switch to UTC-7 when planning what meetings I should attend to next time I’m in the US.

10432 : Separating a click from a move etc

Question

I would like the user to be able to change start and stop dates by moving the time item and dragging the start or stop. I would also like the user to click on the time item to get a new window up with more detailed information. I have problems to find out when the user has clicked on a time item, is there an easy way to do that? The events that I can think of (OnTimeItemAreaClick, OnTimeItemAreaMouseDown…) are all fired together with AfterMove, StartValueResize, and StopValueResize.

Answer

implement OnTimeItemAreaMouseDown, in this event check the Gantt.MouseMoveKind property, it can take on values like none,move,resizew,resizee,linkCreate,timeItemCreate,linkReAssign

This information combined with the standard event parameters like e.Clicks==2 can help you catch a double.

If you just want to catch a single click you should know that we interpet this as a select of that time item. So you can implement OnTimeItem_SelectionChanged to catch these.

 

10420 : Hide scroll buttons in Gantt_ASP

Question

I implement myself the Scaling and Dragging – Buttons(JS:__doPostBack(‘gantt’,’Subtract’), JS:__doPostBack(‘gantt’,’scaledec’), etc. ) in my gantt in ASP.NET.

This works fine, now can i hide the arrows in the DateScaler, because they make no sense anymore in my App ?

Answer

In your formLoad you can set Gantt_ASP.Gantt.DateScaler.ScrollButtonsVisible=false and then the buttons will not show in the generated html

 

10422 : Re-using a gantt in another place

Question

Whats the shortest way to copy all items, settings, properties…. (everything) from one gantt-control to another one? I wanna see everything that is in one gantt also in another gantt. exactly the same.

Answer

The one thing that pops into mind directly is to re-use the class that has the Gantt in it; weather it is a form or a panel or some other win-control; simply instansiate it one more time…

10380 : Action on Grid data in Gantt_ASP

Question

I’m using PlexityHide GTP.NET.WEB.

I’m using this control to display all the event (Grid) with timeline.
Currently, when click on the timeline, the related info will display in other page at the frame below.

I had pass the eventID when OnTimeItem_ClientClick.

My question is, can i do the same as OnTimeItem_ClientClick but apply to the grid.

So far when my mouse point to each row on the grid, the cursor do not change to ‘hand’ and i try to few event like grid_click and etc, there is no response on that.

Please advice.

Answer

Currently the best way to do this is by changing the grid data to a link (href) and in the link describe what action you want to take.

Like if you have a name in a grid cell like “Karlsen” and you want to do something when the user clicks that name:
Instead of adding “Karlsen” to the cell add “<a href=’javascript:__doPostBack(‘Gantt_ASP1′,’SOMEID;SOMEDATA’)’>Karlsen</a> ” then catch the postback in the Form on the server side.

10381 : image on a TimeItem

Question

I want to know how to tile an image on a TimeItem.
I wrote this:< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

item.TimeItemLayout.ImageIndex    =  m_ClipItemIndex;
item.TimeItemLayout.TimeItemStyle =  TimeItemStyle.Image;

Now I see the image yet it is not tiled to the whole duration of the TimeItem.
(I.e the image is not Tiled to the whole duration of the TimeItem, It is shown in it original size and the rest of the TimeItem is not shown)

How can I do this?

Answer

Actually the ImageIndex set in a TimeItemLayout will only be in effect when the time item style is Image.
A better way to add the images to a time item is to use the ImageIndex of the TimeItemTextLayout.
You can add time item texts to your time items and set the text=”” but the ImageIndex to a valid index of the Gantts imageList.
You can use the padding functionality of the timeItemTextLayout to place the image where you want it.
You can add as many timeItemTexts as you need.
 
However this feature was not fully implemented in the 2.0.13.0. You may request a pre release of 2.1 called 2.0.19.0 that has this feature fully implemented from support.

10377 : I cant find TimeItem from specific item like index.

Question

I cant find TimeItem from specific item like index.
How can I find TimeItem from specitfic item in 5 GanttRows?

Answer

To get to a specific time item you need to know the Layer, the GanttRow or the GridNode (you can iterate thru GridNodes if do not have a specific node). Then if you have a GridNode (worst case) you can go like this:

GridNode gn=gantt1.Grid.GridStructure.RootNodes[0];
GanttRow gr = GanttRow.FromGridNode(gn);
TimeItem ti=gr.Layers[theindexofLayer(probably 0 if you only have one layer)][theIndexOfTimeItemWithinLayer];

10318 : How do I serialize a Gantt chart?

Question

How do I serialize a Gantt chart? Do GTP.NET customers roll their own file formats for saving Gantt charts or do you offer something with your product?

 

Answer

Since the Gantt and Grid can be used with datasource and databind we incourage user to hold their data in datasets. The datasets can be persisted as xml or in a database.

This info is from the latest help file; it describes databinding as it is set up in the Gantt_Database sample.

Gantt_Database sample

The sample Gantt_Database shows how to connect the Gantt to a database that has one table for hierarcical grid nodes (project) and one table for time items on these nodes (projects).

 images has been removed (look in the help file for the complete story)

The timeitem table has a foreign key that links to its owning project (TimeItem.ownedby). And the projects has a foreign key that is set to the project parent if it exists. If it does not exists we set this foreign key to -1 or to null.

In the load button of the sample we use the sqladapters to fill the datasets. We create a dataview on the project dataset that filters out the project rows with no parent (firstView.RowFilter="ISNULL(ownedby,-1)=-1";)

We bind the rootnodes of the grid to this dataview with this call: gantt1.GridProperties.RootNodes_DataSourceList=firstView;


		private void button1_Click(object sender, System.EventArgs e)
		{
			dataSet21.Clear();
			dataSet21.project.Clear();
			sqlDataAdapter1.Fill(dataSet21);
			DataView firstView = new DataView(dataSet21.project);
			firstView.RowFilter="ISNULL(ownedby,-1)=-1";
			gantt1.GridProperties.RootNodes_DataSourceList=firstView;

			dataSet_timeitems1.Clear();
			sqlDataAdapter2.Fill(dataSet_timeitems1);

		}
Now the root-nodes will be created from all the rows in the dataview.
The Grid cell values will be resolved using the DataSourceColumn field in the GridColumn (Gantt.GridProperties.Columns):

 images has been removed (look in the help file for the complete story)

For each GridNode that is created we want to check if there should be any sub-nodes and/or time items.
We do this in the event OnNodeInserted:

		private void gantt1_OnNodeInserted(PlexityHide.GTP.Grid aGrid, PlexityHide.GTP.NodeEventArgs e)
		{
		
			object row=e.GridNode.ListItemWhenDataBound();
			object val=e.GridNode.OwningCollection.NodeDataConnect.CurrencyManager.GetItemProperties().Find("id",true).GetValue(row);

			// Set up tree using DataViews, in this sample we only allow for SubLevel zero (root nodes) to have sub nodes
			if (e.GridNode.SubLevel==0)
			{
				DataView subNodeView = new DataView(dataSet21.project);
				if (val is Int32)
					subNodeView.RowFilter="ownedby="+val.ToString();
				else
					subNodeView.RowFilter="ownedby=-1";
			  // Set the SubNodes to bind to the subNodeView
				e.GridNode.SubNodes_DataSourceList=subNodeView;
			}

			// Set up time items in layer 0 with a dataview of the time items dataset
			GanttRow gr=Gantt.GanttRowFromGridNode(e.GridNode);
			DataView timeitemView = new DataView(dataSet_timeitems1.timeitem);
			if (val is Int32)
				timeitemView.RowFilter="ownedby="+val.ToString();
			else
				timeitemView.RowFilter="ownedby=-1";
			gr.Layers[0].NameInDS_Start="start";
			gr.Layers[0].NameInDS_Stop="stop";
			gr.Layers[0].DataSourceList=timeitemView;
			gr.Layers[0].TimeItemLayout="NiceLook";


		}
And that is it. When you change the time items start or stop properties the dataset will be updated. 
When you change the grid cells the dataset will be updated.

But what about moving a time item to a different row?

To handle the move, we actually only want to assign a different foreign key to the TimeItem row in the TimeItem table, 
this has very little to do with the gantt control itself, but we need to react to this operation:

    private void gantt1_OnTimeItem_ChangeRow(PlexityHide.GTP.Gantt aGantt, PlexityHide.GTP.TimeItemEventArgs e)
    {
      // What we really want to do when changing rows in a databound Gantt is to change the data in the dataset to reflect 
      // the change of owner. This change in data will propagte into the Gantt Automatically.
      
      e.Allow=false; // Do not perform the move, let propagation handle it 
      
      DataRowView row=e.TimeItem.ListItemWhenDataBound() as DataRowView;
      DataRowView noderow=e.NewGanttRow.GridNode.ListItemWhenDataBound() as DataRowView;

      row["ownedby"]=noderow["id"];   // Set the OwnedBy value to the id of the new row -> move it   
    }