How to establish alt text for datagrid headers?

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 12
Reputation: kingflux is an unknown quantity at this point 
Solved Threads: 0
kingflux's Avatar
kingflux kingflux is offline Offline
Newbie Poster

How to establish alt text for datagrid headers?

 
0
  #1
Jul 31st, 2007
Hello, I am working in VS.NET 2003 with the original datagrid control. There does not appear to be a published technique for displaying alt text on the grid headers (e.g. mouseover causes a pop-up explaining what the column represents).

Has anyone successfully accomplished this with the Microsoft datagrid or a third party?

Thank you in advance!
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 24
Reputation: atal is an unknown quantity at this point 
Solved Threads: 0
atal atal is offline Offline
Newbie Poster

Re: How to establish alt text for datagrid headers?

 
0
  #2
Aug 1st, 2007
you should use javascript for this to achive for more information visit this website:
http://www.netomatix.com/GridToolTip.aspx
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,580
Reputation: Infarction has a spectacular aura about Infarction has a spectacular aura about Infarction has a spectacular aura about 
Solved Threads: 52
Infarction's Avatar
Infarction Infarction is offline Offline
Battle Programmer

Re: How to establish alt text for datagrid headers?

 
0
  #3
Aug 2nd, 2007
For IE, I think setting the title attribute will do that. I'm pretty sure that this does not work on Firefox however.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: How to establish alt text for datagrid headers?

 
0
  #4
Aug 2nd, 2007
Inherit from BoundColumn and DataGrid classes. Add a public string accessor for the tool tip text in the BoundColumn derived class. Override the OnItemCreated event in your derived DataGrid class. My company is Weblogik so we prefix all our derived classes wl, so you might want to change that.

  1. using System;
  2. using System.Web.UI.WebControls;
  3.  
  4. namespace yourproject.namespace
  5. {
  6. /// <summary>
  7. /// Summary description for wlBoundColumn.
  8. /// </summary>
  9. public class wlBoundColumn : BoundColumn
  10. {
  11. private string headerToolTip;
  12. public string HeaderToolTip
  13. {
  14. get{return headerToolTip;}
  15. set{headerToolTip = value;}
  16. }
  17. }
  18.  
  19. /// <summary>
  20. /// Summary description for wlDataGrid.
  21. /// </summary>
  22. public class wlDataGrid : DataGrid
  23. {
  24. private const string HEADER_TOOLTIP_FORMAT = @"<p title=""{0}"">{1}</p>";
  25.  
  26. protected override void OnItemCreated(DataGridItemEventArgs e)
  27. {
  28. if(e.Item.ItemType == ListItemType.Header)
  29. {
  30. for (int i=0;i < e.Item.Cells.Count;i++)
  31. {
  32. if (Columns[i] is wlBoundColumn)
  33. {
  34. wlBoundColumn col = (wlBoundColumn)Columns[i];
  35. if (col.HeaderToolTip != null)
  36. {
  37. TableCell cell = e.Item.Cells[i]; cell.Text = String.Format(HEADER_TOOLTIP_FORMAT,
  38. col.HeaderToolTip,cell.Text);
  39. }
  40. }
  41. }
  42. }
  43. //invoke base class method
  44. base.OnItemCreated(e);
  45. }
  46. }
  47. }

In your aspx page you need to register a TagPrefix:

  1. <% @Page blah... %>
  2. <%@ Register TagPrefix="wlc" Namespace="yourproject.namespace" Assembly="yourprojectassemblyname" %>
  3.  
  4. <DOCTYPE Blah ...>
  5.  
  6. <html>
  7. <body>
  8. <form>
  9.  
  10. <wlc:wlDataGrid id="wlDataGrid1" runat="server" AutoGenerateColumns="False">
  11. <columns>
  12. <wlc:BoundColumn DataField="fieldname" HeaderText="header" HeaderToolTip="My header tooltip"></wlc:wlBoundColumn>
  13. </columns>
  14. </wlc:wlDataGrid>
  15.  
  16. .
  17. .
  18. .

I have found this works in FireFox (1.5 tested, I haven't tried 2.0), but there seems a strange behaviour, if you 'view page source' it stops working properly afterwards. I don't know if that has anything to do with the page being in a pop-up child window.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 12
Reputation: kingflux is an unknown quantity at this point 
Solved Threads: 0
kingflux's Avatar
kingflux kingflux is offline Offline
Newbie Poster

Re: How to establish alt text for datagrid headers?

 
0
  #5
Mar 3rd, 2008
Hello, Infarction-- There is no title attribute in the DataGrid control. I've checked .NET 1.1, 2.0, and 3.5.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 12
Reputation: kingflux is an unknown quantity at this point 
Solved Threads: 0
kingflux's Avatar
kingflux kingflux is offline Offline
Newbie Poster

Re: How to establish alt text for datagrid headers?

 
0
  #6
Mar 3rd, 2008
Hello, Paul-- I'm finally getting to this. The derived class compiles without errors, I added a line the aspx to register the new TagPrefix, but now I get The directive is missing a 'src' attribute.

Any ideas?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC