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   
    }

10595 : How can I put a scrollbarcolumn in my grid on gantt_asp?

Question

I’m using GTP_asp in web.
How can I put a scrollbarcolumn in my grid on gantt_asp?

Answer

The Gantt supports paging that will split up long dataranges over several pages with page numbers at the bottom of the Gantt.

But if you do not want to page your data but rather scroll it you can do so by enclosing the Gantt_ASP in a scrolling div.

A scrolling div looks like this:

<div style=”border : solid 2px #ff0000; background : #000000; color : #ffffff; padding : 4px; width : 200px; height : 50px; overflow : auto; “>
<Gantt_ASP>
</div>

10592 : Collisiondetection placement

Question

When there is a collision between DateTime items they get arranged one above the other – this is good, however the arrangement (which is shown above and which is below) can change as you zoom and pan. Have you noticed this? Can this be prevented in any sensible fashion? What about a tag or id or something that we could set to force an order – this could be used, as well, to control what the drawing order is when automatic collision detection is not used (if there is not already a means of doing this?

Answer

In the latest version of GTP.NET we use a rule that makes the placement more distinct. We always place the earliest time item in top column, and then they are arranged according to their start date. If you need a different order it is good to know that you can control this placement by setting the SubCol value of the time item. You can also use the event OnCollisionDetect and set the TimeDistinctItems DistinctPosition to control the assigned subcol value.

10658 : How can i know the order user click on the time item?

Question

How can i know the order user click on the time item? I found out that u sort GetSelectedTimeItems by date. Please help. I need it urgently.

Answer

We do not store the order of the selections, I do not think we order the GetSelectedTimeItems for that matter. But you can implement OnTimeItem_SelectionChanged and keep your own collection of selected items.

Just add the e.TimeItem to the collection if e.TimeItem.Selected==true, otherwise remove it from the collection.

10512 : Can we drill down on any bar in the gantt chart?

Question

Can we drill down on any bar in the gantt chart?

Answer

If the question is “Can we catch all possible events on a time item” the answer is yes. The term “drill down” implies that there is data “under” this time item, and there probably is, but that is up to you to decide what that data is. Our components merly offer you a clean way to make changes and presentation to the data you provide.

10541 : Fill one paper

Question

Is there a way with the GTP.Net version to make the gantt fill one page only? For example, if I have 100 rows in the Gantt chart I need them to all print on one page. I have worked with the scaling and the examples that are on your website but I have not found a solution yet.

 

Answer

 

A bit if a hack but why not make a loop and print with decreasing scale until you get HasMorePages==false< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

 

 

10421 : What is the source code which is offered in the $ 1,899.00 package?

Question

What is the source code which is offered in the $ 1,899.00 package (1 Developer License for GTP.NET)? Are they sample codes on how GTP.NET components are used?

Answer

The source code to all samples are included in every licensing scenario.

The source code in the Source code license is the complete c# code to the GTP.NET. This license enables you to build the GTP.NET yourself and debug into GTP.NET. You can fix bugs (we strongly recommend you to coordinate local changes with support), or add your own extensions (not recommended since you loose many of the benefits with allowing us to handle all maintainance and development). Many companies license the source as an insurance for future events.

10414 : Changing mousecursor in Gantt_ASP

Question

Im using the _gantt_OnAreaAttributes() method to set up event handlers inside e.Result for the items on the gantt chart according to their e.AreaKind.

If I leave e.Result as it is then the item appears with the mouse cursor as a “hand” and causes a post back when you click the item. 
Is there something I can put in the e.Result to manipulate the mouse cursor type?

Answer

I thought that this should be as easy as:


    private void Gantt_ASP1_OnAreaAttributes(PlexityHide.GTP.WEB.Gantt_ASP aGantt, PlexityHide.GTP.WEB.AreaAttributeEventArgs e)
    {
      if (e.AreaKind==AreaKind.TimeItem)
      {
        e.Result+=" onmouseover=\"this.style.cursor='crosshair';return true;\" "; // add a cursor switch in mouse over
      }
    }
But I cannot get it to work, and I cannot really understand why. I think this is some browser limitation.
If I set this code in the img tag itself it will change the cursor, but it seems like IE6 will not run onMouseOver's for image maps.
So Sorry, cannot not currently help you. If you figure anything out please let me know...

10411 : How do I make sure my ganttrow is visible for the user?

Question

We’re using plexityHide Gantt 1.3. How do I make sure my selected ganttrow is visible for the user? I’m able to select to row but not to scroll/navigate to it so it’s visible for the user.

Note: The timeItem is not selected by the user in the gantt.

/////////////
_selectedTimeItem = tmpTi;
//Expand selected parent node
GridNode gn = _selectedTimeItem.GanttRow.GridNode;
if (!gn.ParentNode.Expanded){
 gn.ParentNode.Expanded = true;
}
this.Grid.GridStructure.ClearSelections();
gn.RowSelected = true;

Answer

In version 1.3 you will need to set the Gantt.Grid.Gridstructure.TopNode property to the desired node… If it is the last node this will look a bit strange so you might want some logic to set Gantt.Grid.Gridstructure.TopNode to a more appropriate value.

If you upgrade to 2.x you simply call gn.MakeSureVisible().

In 2.x you also have MakeSureVisible calls on TimeItems and cells.

10404 : Adding time items, they all get the same color

Question

Hi I have modified this code from one of the examples but i want to change the colour of some of the bars depending on the data Private Sub gantt1_OnNodeInserted(ByVal aGrid As PlexityHide.GTP.Grid, ByVal e As PlexityHide.GTP.NodeEventArgs) Handles gantt1.OnNodeInserted

            Dim row As Object = e.GridNode.ListItemWhenDataBound()
            Dim val As Object = e.GridNode.OwningCollection.NodeDataConnect.CurrencyManager.GetItemProperties().Find(“id”, True).GetValue(row)
            Dim val2 As String = e.GridNode.OwningCollection.NodeDataConnect.CurrencyManager.GetItemProperties().Find(“name”, True).GetValue(row)
            Dim view As String

            ‘ 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 Then
                Dim subNodeView As DataView = New DataView(dataSet21.project)
                If TypeOf val Is Int32 Then
                    subNodeView.RowFilter = “ownedby=” & val.ToString()
                    Select Case CStr(val2).Trim
                        Case “Shattered”
                            view = “sh”
                        Case Else
                            view = “ELSE”

                    End Select

                Else
                    subNodeView.RowFilter = “ownedby=-1”
                End If
                ‘ Set the SubNodes to bind to the subNodeView
                e.GridNode.SubNodes_DataSourceList = subNodeView
            End If

            ‘ Set up time items in layer 0 with a dataview of the time items dataset
            Dim gr As GanttRow = Gantt.GanttRowFromGridNode(e.GridNode)
            Dim timeitemView As DataView = New DataView(dataSet_timeitems1.timeitem)
            If TypeOf val Is Int32 Then
                timeitemView.RowFilter = “ownedby=” & val.ToString()

            Else
                timeitemView.RowFilter = “ownedby=-1”

            End If

            gr.Layers(0).NameInDS_Start = “start”
            gr.Layers(0).NameInDS_Stop = “stop”
            gr.Layers(0).DataSourceList = timeitemView

            If view = “ELSE” Then
                Dim ti1 As TimeItem = gr.Layers(0).AddNewTimeItem()
                ti1.TimeItemLayout.SelectHandles = Color.Black
                ti1.TimeItemLayout.BrushKind = BrushKind.GradientDiagonal
                ti1.TimeItemLayout.Color = Color.YellowGreen
                ti1.TimeItemLayout.GradientColor = Color.Yellow
            Else
                Dim ti2 As TimeItem = gr.Layers(0).AddNewTimeItem()
                ti2.TimeItemLayout.SelectHandles = Color.Black
                ti2.TimeItemLayout.BrushKind = BrushKind.GradientDiagonal
                ti2.TimeItemLayout.Color = Color.SteelBlue
                ti2.TimeItemLayout.GradientColor = Color.White
            End If

 

 

        End Sub

What do i need to change to do this

at the moment they still come out the one colour

Answer

Since the timeItemLayouts are objects that in this case is being re-used to for all time items you actually change the properties of that single TimeItemLayout over and over. You need to definie two different timeItemLayouts and use them distinctivly.

                TimeItemLayout til1=new TimeItemLayout()
                til1.SelectHandles = Color.Black
                til1.BrushKind = BrushKind.GradientDiagonal
                til1.Color = Color.YellowGreen
                til1.GradientColor = Color.Yellow

                TimeItemLayout til2=new TimeItemLayout()
                til2.SelectHandles = Color.Black
                til2.BrushKind = BrushKind.GradientDiagonal
                til2.Color = Color.SteelBlue
                til2.GradientColor = Color.White

Once you have that you go like this:

            If view = “ELSE” Then
                Dim ti1 As TimeItem = gr.Layers(0).AddNewTimeItem()
                ti1.TimeItemLayout=til1
            Else
                Dim ti2 As TimeItem = gr.Layers(0).AddNewTimeItem()
                ti1.TimeItemLayout=til2
           End If