11547 : Gantt_ASP change the grid columns sort icon

Question

Hello Support, I am using the PlexityHide.Gtp version 3.1.9.8. I want to change the grid columns sort icon. Is it possible to change the sort icon? If yes how to change it (if possible plz provide the code), if no then is there any work around to show some other icon over it because current sort icon is not looking good, the icon is not easily recognized by end user, it looks like digit 7. Thanks in advance for your help.

Answer

In Gantt_ASP you can implement the OnGetResource event.

When called with PlexityHide.GTP.WEB.sort_ascending.gif, PlexityHide.GTP.WEB.sort_descending.gif or PlexityHide.GTP.WEB.sort_empty.gif, supply your own valid url to an image…

< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

 

11546 : Gantt_ASP, adding hyperlink in the grid

Question

I want to add a hyperlink “Delete” for each row in the grid

Answer

 

Add a extra column that has nothing in the DataSourceColumn:

        Gantt_ASP1.Gantt.Grid.Columns.AddNew(PlexityHide.GTP.CellType.SingleText);
        Gantt_ASP1.Gantt.Grid.Columns[1].DataSourceColumn = “”;

Then when the row is initiated, inject your callback link:

 

    void Grid_OnNodeInserted(Grid aGrid, NodeEventArgs e)
    {
        // For each new node we set up databind for subnodes…
        e.GridNode.SubNodes_DataSource = (e.GridNode.ListItemWhenDataBound() as DataRowView).CreateChildView(“subnodes”);

        string postbackref = “DELETE:” + Gantt_ASP1.GridNodeKey(e.GridNode.GetCell(1).GridNode);
        string deletecontent = “<a href=\”javascript:” + Page.ClientScript.GetPostBackEventReference(this, postbackref) + “\”>Delete</a>”;
        e.GridNode.GetCell(1).Content.Value = deletecontent;

        // and for time items
        GanttRow gr = Gantt.GanttRowFromGridNode(e.GridNode);
        gr.IncreaseRowHeightOnCollision = true;
        gr.IncreaseRow_SuggestedHeightPerItem = 20;
        gr.Layers[0].TimeItemLayout = “spacy”;
        gr.Layers[0].NameInDS_Identity = “id”;
        gr.Layers[0].NameInDS_Start = “start”;
        gr.Layers[0].NameInDS_Stop = “stop”;
        gr.Layers[0].DataSource = (e.GridNode.ListItemWhenDataBound() as DataRowView).CreateChildView(“timeitems”);
    }

Here I gave it a PostBack to the page (Page.ClientScript.GetPostBackEventReference(this…  )
So we need to make the page a IPostBackEventHandler
Just add IPostBackEventHandler behind the superclass Page:

public partial class _Default : System.Web.UI.Page, IPostBackEventHandler

Right click the IPostBackEventHandler and choose Implement interface:

Implement the handling code:

    private bool _deferActualDeleteUntilViewStateIsFullyApplied;
    private string _idToDelete;
    #region IPostBackEventHandler Members

    public void RaisePostBackEvent(string eventArgument)
    {
        string[] parts=eventArgument.Split(‘:’);
        if (parts.Length > 1)
        {
            if (parts[0] == “DELETE”)
            {
                _deferActualDeleteUntilViewStateIsFullyApplied = true;
                _idToDelete = parts[1];
            }
        }
    }

    #endregion

We do not want to delete directly, since the GridNodes are not sorted yet…
Instead we delete in the OnClientSideChangesApplied event, if applicable:

    protected void Gantt_ASP1_OnClientSideChangesApplied(object sender, EventArgs e)
    {
        if (_deferActualDeleteUntilViewStateIsFullyApplied)
        {
            GridNode gn_todelete = Gantt_ASP1.GridNodeFromKey(_idToDelete);
            if (gn_todelete != null && gn_todelete.ListItemWhenDataBound() != null)
            {

                (gn_todelete.ListItemWhenDataBound() as DataRowView).Delete();
            }
        }

     // Save the changes maybe…

    }

 

 

11231 : Script manager is ambiguous in the namespace system.Web.UI

Question

I went into vb.net5 and started a new web site and tied doing the instructions for To create an ajax< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

enabled Gantt chart. The error is Script manager is ambiguous in the namespace system.Web.UI.

 

After this I tried adding it to my current  ajax aspx vb.net 2005 and got the same errors.  And can’t get the old versions in source safe.  The error is Script manager is ambiguous in the namespace system.Web.UI.  I think something got messed up in the .net framework or something.  Don’t know how to fix this.

Answer

My guess is that your web.config is messed up.

 

Best solution?

 

Create a new project drag an update panel to it (with the VS and ajax version you want).

Copy the content from that web.config to your actual project.

 

 

More details:

Maybe you have a row like this:

<add assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/>

 

And a row like this:

<add assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/>

 

In the web.config? Then VS does not know where to go for system.web.extensions…

 

 

11168 : How do I use a CSS file with the GTP.NET?

Question

How do I use a CSS file with the GTP.NET?

Answer

Normally you do not want to add a css of your own to change the styles of the grid since one is generated for you based on the settings of the CellLayouts. This way you can have almost the same view in WinForms and ASP.NET.

The class names of the cells is taken from the names of the used CellLayout. You can choose to use an External style sheet or a style sheet section in the rendered page.

This property comes into play: ExternalStyles, When setting ExternalStyles to true the css stylesheet is NOT embedded into the rendered html. Intstead you must add an attribute to the head section. You will also need to create the theganttstyles.css and you can do this by calling UpdateExternalStyles with the file name of your choice. If you leave ExternalStyles to false (default) you do not need this, but on the other hand ajax does not update the head section so under certain circumstances you can run into troubles using embedded styles. 

UpdateExternalStyles,  When setting ExternalStyles to true the css stylesheet is NOT embedded into the rendered html.

Typical scenario for when to create to the css file:
Gantt_ASP_Main.ExternalStyles=true; // You have decided to use external styles, this might be set in the object inspector already LoadMainProjectData(); // You fill the Gantt with data AND you probably create some CellLayouts format grid cells
if (!File.Exists(Page.MapPath(“GanttStyle.css”))) // If you have no need for dynamic styles, the file does not need to be written every time… Gantt_ASP_Main.UpdateExternalStyles(Page.MapPath(“GanttStyle.css”)); // This call reads the CellLayouts and create the css content, and saves the file.   

 

11229 : Resizing the TimeItem”s Region

Question

When the GanttRow.CollisionDetect and GanttRow.IncreaseRowHeightOnCollision properties are set to true, the TimeItems that are not in a collision-area are shown as filling the entire height of the now expanded row.
When trying to resize them using the suggested solution in Q10210, the drawing itself shows a regular sized TimeItem, but the text and all the events still apply to the old Region, which covers the entire height of the row.
How do I redefine the TimeItem’s Region so that I will have a regular-sized and regular-behaving TimeItem while still enjoing the benefits of showing the collisions on an increased row?

Answer

This is how to use the OnTimeItem_UserDrawBounds and  OnTimeItem_UserDraw together:

In the OnTimeItem_UserDraw event change the given Rect and Bounding  Region (make them as thin as you need)
Start with the rect and create a new region:
       e.Rect=rect;
       e.BoundingRegion = new Region(rect);

In the OnTimeItem_UserDrawBounds you must do the same(assign new  e.Rect and e.BoundingRegion), since this event Is fired when the  logic is finding out the size of the time item for other reasons  than drawing.

 

    private void buttonSetUpTestSizeOverride_Click(object sender, EventArgs e)
    {
      gantt1.OnTimeItem_UserDraw += new TimeItemEvent(gantt1_OnTimeItem_UserDraw);
      gantt1.OnTimeItem_UserDrawBounds += new TimeItemEvent(gantt1_OnTimeItem_UserDrawBounds);
      GridNode gn=new GridNode();
      gantt1.Grid.RootNodes.Insert(0,gn);
      GanttRow gr = GanttRow.FromGridNode(gn);
      TimeItem ti=gr.Layers[0].AddNewTimeItem();
      ti.Start=gantt1.DateScaler.StartTime.AddDays(5);
      ti.Stop=ti.Start.AddDays(10);
      ti.TimeItemLayout=ti.TimeItemLayout.Clone() as TimeItemLayout;
      ti.TimeItemLayout.TimeItemStyle=TimeItemStyle.User;
    }

    /// <summary>
    /// This event can help you override how a time item is perceived in the TimeItemFromXY (the active clickable area )
    /// </summary>
    void gantt1_OnTimeItem_UserDrawBounds(Gantt aGantt, TimeItemEventArgs e)
    {     
      GraphicsPath gp=new GraphicsPath();
      gp.AddEllipse(e.Rect);
      e.BoundingRegion=new Region(gp);
    }

    /// <summary>
    /// …and this event helps you draw something in that area.
    /// Note that the two areas can differ, its up to you, but it will a bit strange…
    /// </summary>
    void gantt1_OnTimeItem_UserDraw(Gantt aGantt, TimeItemEventArgs e)
    {
      GraphicsPath gp = new GraphicsPath();
      gp.AddEllipse(e.Rect);
      e.G.DrawPath(new Pen(Color.Blue),gp);     
    }

11228 : How can I choose which printer to use?

Question

 

Using the print facilities of your object I can just launch the print preview based on the current default printer and its configurations (like paper size, etc).< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

I wonder how can do to let the user to select which printer to use and to properly configure it before printing the gantt.

 

Answer

 

Stole this more or less from MSDN:

public void Printing(string printer) {
 
try {
    streamToPrint =
new StreamReader (filePath);
   
try {
      printFont =
new Font(“Arial”, 10);
      PrintDocument pd =
new PrintDocument();
      pd.PrintPage +=
new PrintPageEventHandler(pd_PrintPage);
     
// Specify the printer to use.
      pd.PrinterSettings.PrinterName = printer;

      if (pd.PrinterSettings.IsValid) {
         pd.Print();
      }
     
else {   
         MessageBox.Show(
“Printer is invalid.”);
      }
    }
   
finally {
      streamToPrint.Close();
    }
  }
 
catch(Exception ex) {
    MessageBox.Show(ex.Message);
  }
}

 

 

11126 : Bigger jumps on datescaler scrolling

Question

I would like to change the user scroll step. I want the user to take bigger steps in time when they press the datescaler scrollbuttons. How can I go about that?

Answer

One way to solve that is to implement the OnBeforeScaleOrSpanChange event and change the deault values.

    private void buttonSetUpBiggerJumpOnTimeScroll_Click(object sender, EventArgs e)
    {
      gantt1.DateScaler.OnBeforeScaleOrSpanChange += new BeforeScaleOrSpanChangeEventHandler(DateScaler_OnBeforeScaleOrSpanChange);
    }

    void DateScaler_OnBeforeScaleOrSpanChange(DateScaler dateScaler, BeforeScaleOrSpanChangeArgs e)
    {
      if (e.DateScalerChangeKind==DateScalerChangeKind.userpan)
      {
        TimeSpan defaultjumpsize=e.NewStartTime-gantt1.DateScaler.StartTime;
        // 4 times bigger jumps than default…
        e.NewStartTime = gantt1.DateScaler.StartTime + defaultjumpsize + defaultjumpsize + defaultjumpsize + defaultjumpsize;
        e.NewStopTime = gantt1.DateScaler.StopTime + defaultjumpsize + defaultjumpsize + defaultjumpsize + defaultjumpsize;
       
      }
    }

11150 : if I want to add attributes like mouseover for the time times how do I do that?

Question

< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

if I want to add attributes like mouseover for the time times how do I do that? Lets say for a button if I want to add a mouse over event in vb.net we can add like this

 

Button1.attributtes.add(“mouseover”,”mouseover()”)

 

I tried use ClientSideJavaScript_TimeItemInit event.

 

Is there any function avilable in plexityhide which i can add mouseover evenet for timeitem.

 

Answer

 

Sure, Go like this:

Gantt_ASP

.ClientSideJavaScript_TimeItemInit = “aImgElement.onmouseover=(function(event){alert(‘hello’);});\r\n”;

 

11143 : Is there a way to change the style of selected items?

Question

Is there a way to change the style of selected items?

Answer

The built in selection highlight is limited to the TimeItemLayout.SelectHandles=color, but if you want something more fancy it is really easy to implement the OnTimeItem_SelectionChanged event and simply change the TimeItemLayout if the time item is selected or de-selected.

The event is called both for selection and de-selection, so that you can set the timeitemlayout back to the original. Just check the e.TimeItem.Selected, true=selected false=de-selected.

11123 : I want to extend the grid columns so that they always fill the space in grid

Question

 

How can I automatically extend the grid column to use up all the space in the grid?

 

Answer

 

Implement the Grid.Resize event and do something like this:

 

< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

    void Grid_Resize(object sender, EventArgs e)

    {

      if (gantt1.Grid.Columns.SumWidth()<gantt1.Grid.Width)

      {

        gantt1.Grid.Columns.FirstVisibleColumn().Width+=gantt1.Grid.Width-gantt1.Grid.Columns.SumWidth();

      }

    }