This is a migrated thread and some comments may be shown as answers.

Custom tooltip text for GridExpandColumn

5 Answers 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam Cole
Top achievements
Rank 1
Adam Cole asked on 15 Jun 2009, 06:35 PM

I hide the default ExpandCollapseColumn and create my own custom column using GridExpandColumn.  My customed column is called "btnExpandColumn".

I use following code to hide/show my custom column, but for some reason, it doesn't allow me to change the tooltip text.

I assume to change the tooltip text, I just need to use:
    col.ToolTip = "My custom text";

Is it correct?


protected void rgPatientList_PreRender(object sender, EventArgs e)
    {
        foreach (GridColumn col in rgPatientList.MasterTableView.RenderColumns)
        {
            if (col.UniqueName == "ExpandColumn")
            {
                col.Display = false;
            }
        }

        foreach (GridDataItem dataItem in rgPatientList.Items)
        {
            GridImageButton btn = (GridImageButton)dataItem["btnExpandColumn"].Controls[0];
            if (!dataItem.Expanded)
            {
                btn.Visible = true;
            }
            else if (dataItem.Expanded)
            {
                btn.Visible=false;
            }
        }    

    }

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Jun 2009, 06:21 AM
Hello Adam,

You can set the tooltip for the GridExpandColumn as shown in the code below:
c#:
 protected void rgPatientList_PreRender(object sender, EventArgs e) 
    { 
        rgPatientList.HierarchySettings.ExpandTooltip = "My custom text"
    } 

Thanks
Princy.
0
Adam Cole
Top achievements
Rank 1
answered on 18 Jun 2009, 06:14 PM
Wow, it's so easy.

Thanks for you help.  =)
0
Shinu
Top achievements
Rank 2
answered on 19 Jun 2009, 04:25 AM
Hi Adam,

You may also refer the following help article which explains how to localize tooltips in Grid.
Localizing the grid messages

Thanks
Shinu
0
Lucania
Top achievements
Rank 1
answered on 16 May 2012, 03:32 AM
Hi,

I have a radgrid with 3 levels of nesting, and I'd like to have a different tooltip for the expand/collapse on each level, is this possible? For example, the tooltips might be "Show tasks", "Hide tasks" and the next level might be "Show notes", "Hide notes" to show/hide the notes attached to the selected task.

Thanks for any help.

ROSCO
0
Richard
Top achievements
Rank 1
answered on 18 May 2012, 07:47 PM
Rosco,

You can customize the expand button and collapse button tooltip messages by using the following approach:

Default.aspx:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
 
    foreach(GridDataItem dataItem in RadGrid1.Items)
    {
        Button btn = (Button)dataItem["ExpandColumn"].Controls[0];
 
        if (!dataItem.Expanded)
        {
 
            switch (dataItem.OwnerTableView.Name)
            {
                case "Customers":
                    btn.ToolTip = "Expand Customer";
                    break;
                case "Orders":
                    btn.ToolTip = "Expand Order";
                    break;
                default:
                    // do nothing
                    break;
            }
        }
        else if (dataItem.Expanded)
        {
            switch (dataItem.OwnerTableView.Name)
            {
                case "Customers":
                    btn.ToolTip = "Collapse Customer";
                    break;
                case "Orders":
                    btn.ToolTip = "Collapse Order";
                    break;
                default:
                    // do nothing
                    break;
            }
        }
 
    }     
 
}

Hope this helps!
Tags
Grid
Asked by
Adam Cole
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Adam Cole
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Lucania
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or