10312 : Selection of a TimeItem after a row change

Question

When I select a TimeItem, it works. If I move the TimeItem to another point on the same row, it remains selected. When I move the given TimeItem to another row then when it arrives at the given row it is no longer selected.

Interestingly enough, when I breakpoint the OnTimeItem_ChangeRow event, the TimeItem shows up as being selected. I also checked the OnTimeItem_AfterMove and the TimeItem shows up as being selected there, too.

Is there an event or setting that I need to change in order for the TimeItems to keep their selection status after a gantt row change?

Answer

I tried this and I cannot repeat it. My guess now is that your are doing this from a data bound sample and those actually re-create a new time item when the datarow has been changed. So if this is the case; what you can do is to catch the first new time item after such a row move, and select it; do this in the OnLayer_InsertComplete event…

Let me know if I’m not right, and please enclose a sample that shows this. TIA

10245 : GTP.NET.WEB How to get rid of the PostBack events

Question

GTP.NET.WEB How to get rid of the PostBack events on the Rows when click on the Row of Gantt, such as _doPostBack(‘Grantt_ASP1′,’Row:0’), _ doPostBack(‘Grantt_ASP1′,’Row:1’), ect., We only need the PostBack events for Add and subtract.

Answer

Implement the OnAreaAttributes event. This event enables you to override the resulting area definition.

Untouched the grid row area definition looks like this:

<map name=’IMMapRow2Gantt_asp2′><area href=”javascript:__doPostBack(‘Gantt_asp2′,’ROW:2′)”  shape=’rect’ coords=’0,0,340,19′></map>

But since you do not want the postback in this case you must change the href.

    private void Gantt_ASP1_OnAreaAttributes(PlexityHide.GTP.WEB.Gantt_ASP aGantt, PlexityHide.GTP.WEB.AreaAttributeEventArgs e)
    {
      if (e.AreaKind==PlexityHide.GTP.WEB.AreaKind.TimeItemRow)
      {       
         // The default value of e.Result is formed like this href=\”javascript:__doPostBack(‘Gantt_ASP1′,’ROW:0;1’)\”
       
        e.Result=””; // You can clear that out to remove the postback. You can set another href to do some client side script…
      }
    }

10265 : The Look-and-feel of DateScaler has changed. It displays only date of the month but not week marks?

Question

The Look-and-feel of DateScaler has changed. It displays only date of the month but not week marks. How do I set DateScaler to show day of the week (e.g. Monday)?

Answer

Regarding the missing week numbers, this is only an issue in 2.0, and you set DateScaler.UseDayNumbersNotWeeks=false to get the week numbers back.

10233 : Iterate all time items

Question

How do I get all the timeitems I have?
Something like gnt.TimeItemArea.Items does not exist.
And

For i = 0 To GNT_Plan.Grid.RootNodes.Count – 1
  For j = 0 To GNT_Plan.Grid.RootNodes(i).subnodes.count – 1
  Next
Next

gives me all nodes, but how do I get all timeitems?

When a special timeitem is clicked, I want all Timeitems belonging to this one (this are not only childs) to change their color or something. They are not linked and they are no childs in this case, just belonging to a special group.

So how can I parse through all timeitems on my Gantt?

Thanks a lot!

Answer

The code belows iterates all the nodes and all the time items in all layers on those nodes, to be complete the samples also iterates the time item texts and time item links…

 Private Sub buttonCompleteIteration_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles buttonCompleteIteration.Click
   ‘ The root-level of the grid nodes you access this way;
   Dim i As Integer=0
   Do While i<gantt1.Grid.RootNodes.Count
  DoCompleteIterationForOneNode(gantt1.Grid.RootNodes(i))
    i += 1
   Loop
 End Sub

 Private Sub DoCompleteIterationForOneNode(ByVal gn As GridNode)
   ‘ Each gridnode has one cell per column
   Dim i As Integer=0
   Do While i<gn.GridStructure.Columns.Count
    Dim o As Object=gn.GetCell(i).Content.Value
    i += 1
   Loop

   ‘ Each gridnode that is part of a gantt-grid has a GanttRow
   Dim gr As GanttRow=GanttRow.FromGridNode(gn)

   ‘ Each GanttRow has layers, the normal scenario is that the GanttRow only has one layer
   i = 0
   Do While i<gr.Layers.Count
  ‘ Each Layer has time items
  Dim ii As Integer=0
  Do While ii<gr.Layers(i).Count
    ‘ Each Layer has time items
    Dim ti As PlexityHide.GTP.TimeItem=gr.Layers(i)(ii)

    ‘a Time item can have time item texts
    Dim iii As Integer=0
    Do While iii<ti.TimeItemTexts.Count
   ti.TimeItemTexts(iii).Text=””
     iii += 1
    Loop

    ‘ and a time item can also have links….       
    Dim links As ArrayList=gantt1.TimeItemLinks.GetLinksFromStart(ti)

    iii = 0
    Do While iii<links.Count
   Dim til As TimeItemLink=CType(IIf(TypeOf links(iii) Is TimeItemLink, links(iii), Nothing), TimeItemLink)
   ‘ Once you have a link you can access the seperate time items
   Dim ti1 As TimeItem=til.Target
   Dim ti2 As TimeItem=til.Start
     iii += 1
    Loop

   ii += 1
  Loop

    i += 1
   Loop

   ‘ A grid node may have sub-nodes….
   i = 0
   Do While i<gn.SubNodes.Count
     DoCompleteIterationForOneNode(gn.SubNodes(i))
    i += 1
   Loop

 End Sub

 

10241 : Limitation of move and Pauses in time items

Question

i’m evaluating the component and i have some question:

1) i see in the sample Gant_ms_look.exe that is possible with drag and drop move up and down the time line (it have to be possible only left and right for changing during and position) and in the grid the item stay in the same location!??!?

2) is it possible put in pause (non only ono but also several) an activity?

Answer

1) Degrees of freedom is completly configurable by the developer. See properties on TimeItemLayout 

 AllowChangeRow 
 AllowLinkReAssignStart 
 AllowLinkReAssignTarget 
 AllowLinkSelectionStart 
 AllowLinkSelectionTarget 
 AllowMove 
 AllowResizeEast
 AllowResizeWest 

2) There is no limitation in how many time items you can put on a row. You can implement a pause as two time items with a third time item with a different look between, or you can do as the sample Gantt_TimeItems user draw sample where an object, holding extra domain specific information, was stored in the UserReference property of the time item and then retrieved on drawing of the time item to indicate the pause or break time.

 

10219 : Double click time item and bring up a dialog

Question

I would like to be able to double click on an item in the chart and have a popup window that modifies the data and writes it back to our database.  How do I do this?

Answer

This is how you can find out the time item actually double clicked. To change it and update your DB; I leave that up to you, but the best approach would be to use databind for time items See the Gantt_Database or Gantt_DataBind sample in the general download. 

    private void gantt1_OnTimeItemAreaDoubleClick(object sender, System.EventArgs e)
    {
      if (gantt1.FocusedTimeItem!=null)
      {
        MessageBox.Show(gantt1.FocusedTimeItem.GanttRow.GridNode.Index.ToString()+”.”+gantt1.FocusedTimeItem.Index.ToString());
      }
    }

Or if you want find a time item from a given pixel (sample in VB.Net):

Dim selectedTI As TimeItem = gnt_Planung.TimeItemFromPoint(gnt_Planung.TimeItemArea.PointToClient(MousePosition))
 
If Not selectedTI Is Nothing Then
     
MsgBox(selectedTI.GanttRow.GridNode.GetCell(0).Content.Value + ” Start:” + selectedTI.Start.ToString())
 
End If

10247 : Clear the Gantt

Question

I am using my gantt for some different views and I am able to switch those views. I use one gantt for those views, because most methods are the same, only the gantt is filled or displayed in another way.

To clear my gantt before re-filling, I use:

GNT_Plan.Grid.GridStructure.Columns.Clear()

GNT_Plan.Grid.GridStructure.RootNodes.Clear()

This works in most cases, but sometimes gives me strange errors. What is the fastest and most effective way to clear my gantt (columns and nodes with subnodes and timeitems and links)?

Answer

What you do should be enough in a perfect world. What might happen is that the structure under a GridNode, like sub nodes, gantt rows, layers, time items and their texts and links are not released because that we have missed to unlink them correctly. If I’m not misinformed you are still using the 1.3, and we do not add anything to this version. All the quality improvement goes into the 2.0 version

To make a long story short; To be safe make sure you null out focused cell, and focused time item for starters, then you should probably clear each layer of time items, each GanttRow of Layers etc….

 

10216 : I was not able to show task notes icon, as appears in MS Project. how can i a picture in a grid cell?

Question

I was not able to show task notes icon, as appears in MS Project. how can i insert a picture in a grid cell?

Answer

You need to assign an imagelist with your icons to Gantt.GridProperties.ImageList.

Every cell has a CellLayout that controls the rendering properties of the cell. You can set the CellLayout.ImageIndex_Select and CellLayout.ImageIndex_UnSelect to an imagelist index. These values will be used when the cell is selected and not selected respectivly.

 

 

10571 : Time items with a color gradient?

Question

what should I do that the time items appear in 3d? I mean to get a color gradient?

Answer

In GTP.NET you can set the TimeItemLayout this way:

ti1.TimeItemLayout=new TimeItemLayout();
ti1.TimeItemLayout.BrushKind=BrushKind.GradientDiagonal;
ti1.TimeItemLayout.Color=Color.YellowGreen;
ti1.TimeItemLayout.GradientColor=Color.Yellow;

In phGantTimePackage you can get a gradient effect doing like this:
time.Style = txTimeStyle.tsPipe;