Usage of the dhtmlxGantt2.vb class....

Coordinator
Sep 30, 2013 at 9:58 PM
Dim sf1 As String = dhtmlxGantt2.ScaleFormat(" ", dhtmlxGantt2.DateFormatEnum.dd, dhtmlxGantt2.DateFormatEnum.mmm, dhtmlxGantt2.DateFormatEnum.yyyy)
                Dim sf2 As String = dhtmlxGantt2.ScaleFormat("", dhtmlxGantt2.DateFormatEnum.dd)
                dhtmlxGantt2.Initialize()
                dhtmlxGantt2.Title = "Ms Project Preview"
                dhtmlxGantt2.SetScale(dhtmlxGantt2.scaleUnitEnum.week, 1, sf1)
                dhtmlxGantt2.AddSubScale(dhtmlxGantt2.scaleUnitEnum.day, 1, sf2)
                dhtmlxGantt2.SetScaleHeight(2, 20)
                dhtmlxGantt2.AddRightSidePattern("", dhtmlxGantt2.PatternEnum.users, "")
                dhtmlxGantt2.AddBarTextPattern("", dhtmlxGantt2.PatternEnum.text, "")
                dhtmlxGantt2.HideBarText = True


                ' add the tasks from a database. define your own dataTable here and read from it
' as the code below is my own. I am using one table that has both tasks and predecessor fields based on an import from ms project file. The critical field is used for the priority field in my case.
                Dim tskDT As DataTable = SQLCompact.OpenDataTable("select * from Ms_project order by id")
                For Each tskRow As DataRow In tskDT.Rows
                    Dim strID As String = tskRow("Id").ToString()
                    Dim strParent As String = tskRow("ParentId").ToString()
                    Dim strStart As String = tskRow("Start").ToString
                    Dim strFinish As String = tskRow("Finish").ToString
                    Dim strDuration As String = tskRow("Duration").ToString
                    Dim strProgress As String = tskRow("PercentageComplete").ToString
                    If strProgress <> 0 Then strProgress = Math.Round(Val(strProgress) / 100, 0)
                    Dim strCritical As String = tskRow("Critical").ToString()
                    Dim strText As String = tskRow("Name").ToString
                    Dim strPred As String = tskRow("Predecessors").ToString
                    Dim strResources As String = tskRow("ResourceNames").ToString()
                    Dim strWBS As String = tskRow("OutlineNumber").ToString
                    Dim strSummary As String = tskRow("Summary").ToString
                    Dim bOpen As Boolean = IIf((strSummary = "Y"), True, False)
                    Select Case strCritical
                        Case "Y" : strCritical = "1"
                        Case "N" : strCritical = "3"
                        Case Else : strCritical = "3"
                    End Select
                    dhtmlxGantt2.AddTask(strID, strText, strStart, strFinish, strDuration, strProgress, strParent, bOpen, strID, strResources, strPred, strCritical)
                    If Len(strPred) > 0 Then
                        dhtmlxGantt2.AddLink(strPred, strID, dhtmlxGantt2.LinkTypeEnum.finish_to_start)
                    End If
                Next
                WebSite.File_Write("~/gantt.html", dhtmlxGantt2.Render)
                regLeft.IFrameUrl = "gantt.html"