Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
Get primary key value to tooltip in Gantt
posted

-Using UltraChart
-LinqDataSource on page is pulling:
Select="new (ProjStatus, ProjStartDate, ProjDueDate, ProjTitle, ProjID)"
-my columns tag:
    <Columns EndTimeColumnIndex="2" ItemLabelsColumnIndex="4"
                    StartTimeColumnIndex="1" />

My question is:
I’d like to pass the “ProjID” value to my Tooltips.FormatString ?
I know I can get the date range(start  end) or label of the item(ItemLabelsColumIndex) into the tooltip, but I would like to get the ProjID value into the tooltip.
Could I leverage a different additional column index attribute within the columns tag and access it within the tooltip somehow?  Other, better method?
ANY ideas or suggestions would be appreciated.
-Gary

 

Parents
No Data
Reply
  • 26458
    Suggested Answer
    Offline posted

    You should be able to implement IRenderLabel to solve this issue. What you're essentially doing is intercepting the tooltip string before it shows up and customizing it. The concept is fairly simple:

    private void Page_Load(object sender, EventArgs ev)
    {
        UltraChart1.Data.DataSource = DemoTable.Table(4);

        Hashtable labelHash = new Hashtable();
        labelHash.Add("CUSTOM", new MyLabelRenderer());
        UltraChart1.LabelHash = labelHash;

        UltraChart1.Tooltips.FormatString = "<CUSTOM>";
    }

    public class MyLabelRenderer : IRenderLabel
    {
        public string ToString(Hashtable context)
        {
            string label = "my string";
            return label;
        }
    }

    When the tooltip is about to be displayed, IRenderLabel.ToString will be called. The return string will be your tooltip. If you look at context hash table, it has all kinds of useful information, like the item row, column, start date, end date, series, task, etc. You will have to provide the means for this method to access your datasource and extract the necessary information based on the stuff in the context.

Children
No Data