Our Shop 



Wednesday, May 12, 2010

Implementing selected Grid rows in Gantt_ASP



To get the selected, yellow, row to function when pressing the Select link in the cell read on…

   1: /// Add a Select button in the grid
   2: Gantt_ASP1.Gantt.Grid.Columns.AddNew(PlexityHide.GTP.CellType.SingleText);
   3: Gantt_ASP1.Gantt.Grid.Columns[2].DataSourceColumn = "";
   4: Gantt_ASP1.OnPostBackEvent += new EventHandler(Gantt_ASP1_OnPostBackEvent);
   5: CellLayout cl = new CellLayout();
   6: cl.BackgroundColor = Color.Yellow;
   7: cl.BackgroundUse = true;
   8: cl.Name = "SelectedRow";
   9: Gantt_ASP1.Gantt.Grid.CellLayouts.Add(cl);

The code above is added to the page load; it adds a column, it adds an eventhandler for OnPostBack, and it adds cellLayout that we will use to highlight the selected row.

I also implement the OnCellContentTuning event to add a link in the cell that is in column 2

   1: void Gantt_ASP1_OnCellContentTuning(Gantt_ASP aGantt, CellContentTuningArgs e)
   2: { 
   3:     if (e.Cell.Column.Index == 2)
   4:     {
   5:         if (e.Cell.GridNode != null)
   6:         {
   7:             string postbackref = "Select:" + Gantt_ASP1.GridNodeKey(e.Cell.GridNode);
   8:             e.Content = "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(aGantt, postbackref) + "\">Select</a>";
   9:         }
  10:     }
  11: }

The implementation of the OnPostBack:

   1: void Gantt_ASP1_OnPostBackEvent(object sender, EventArgs e)
   2: {
   3:     string[] parts = Page.Request.Params[2].Split(':');
   4:     if (parts.Length > 1)
   5:     {
   6:         if (parts[0] == "Select")
   7:         {
   8:             GridNode gn = Gantt_ASP1.GridNodeFromKey(parts[1]);
   9:             if (gn != null)
  10:             {
  11:                 Gantt_ASP1.Gantt.Grid.FocusedCell = gn.GetCell(0);
  12:                 this.ViewState["SelectedNode"] = parts[1];
  13:             }
  14:         }
  15:     }
  16: }

In the code above I set the ViewState variable “SelectedNode” to the key of the GridNode

And finally I implement the event OnClientSideChangesApplied to apply the CellLayout to the row that is defined by the ViewState variable:

   1: protected void Gantt_ASP1_OnClientSideChangesApplied(object sender, EventArgs e)
   2: {
   3:         string s = this.ViewState["SelectedNode"] as string;
   4:         if (s != null)
   5:         {
   6:             GridNode gn = Gantt_ASP1.GridNodeFromKey(s);
   7:             if (gn != null)
   8:             {
   9:                 gn.SetCellLayoutOnAll(Gantt_ASP1.Gantt.Grid.CellLayouts.GetFromName("SelectedRow"));
  10:             }
  11:         }
  13: }



This is exactly what I wanted to read, hope in future you will continue sharing such an excellent article
Best JAVA Training in Chennai
JAVA Training
This could be one of the most useful blogs I have ever come across on this technology. I am a newbie to this technology. Great work admin.
Best Hadoop Training in Chennai
Best hadoop training institute in chennai
Big Data Hadoop Training in Chennai
IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.

IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.

corporate training in chennai corporate training in chennai

corporate training companies in india corporate training companies in india

corporate training companies in chennai corporate training companies in chennai

I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai
I truly appreciate just perusing the entirety of your weblogs. Just needed to educate you that you have individuals like me who value your work. Unquestionably an extraordinary post. Caps off to you! The data that you have given is exceptionally science training in chennai

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]


Support intro


FAQ phGantTimePackage


FAQ general