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

Sum of the Values in a tooltip

7 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Suderson
Top achievements
Rank 1
Suderson asked on 12 Aug 2011, 08:27 AM
Hi
My Client has planned to buy the telerik controls for windows form. Before that, he like to check whether it has the below functionality

I'm populating a  rad GRid from an XML File,. I've a Numeric Column in my Grid.

When my user multi selects the numeric column, then it has to add the values and show it in a tool tip simultaneoiusly. Is it possible. Kindly help us.

7 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 12 Aug 2011, 02:18 PM
Hello Suderson,

Thank you for writing.

To achieve such behavior you should handle the grid ToolTipTextNeeded event, perform the desired calculations, and assign the result as a tooltip:
void radGridView1_ToolTipTextNeeded(object sender, Telerik.WinControls.ToolTipTextNeededEventArgs e)
{
    decimal sum = 0;
    foreach (GridViewRowInfo row in radGridView1.SelectedRows)
    {
        sum += Convert.ToDecimal(row.Cells["Number"].Value);
    }
    e.ToolTipText = sum.ToString();
}

I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.
 
All the best,
Stefan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Suderson
Top achievements
Rank 1
answered on 12 Aug 2011, 02:38 PM
Hi
Thanks a lot. It works. But we have a issue in that too.

When I select few rows, and mouseover the column, am getting the tool tip. But when i scroll the grid and move to some other rows which is not selected and mouse over the column, I'm getting the Sum as the value and not the exact value in the tool tip.

Kindly help on this
0
Stefan
Telerik team
answered on 15 Aug 2011, 12:15 PM
Hi Suderson,

Thank you for your reply.

If I understand correctly, you would like to show the tooltip only when data cells are hovered and not for the header or add new row cells. If this is the case, please check the type of the sender in the ToolTipTextNeeded event and it if is data cell, then display the tooltip:
void radGridView1_ToolTipTextNeeded(object sender, Telerik.WinControls.ToolTipTextNeededEventArgs e)
{
    GridDataCellElement dataCell = sender as GridDataCellElement;
 
    //show tooltips only when data cells are hovered
    if (dataCell != null)
    {
        decimal sum = 0;
        foreach (GridViewRowInfo row in radGridView1.SelectedRows)
        {
            sum += Convert.ToDecimal(row.Cells["Number"].Value);
        }
        e.ToolTipText = sum.ToString();
    }
}

In regards to the second part of your question, I am not sure that I am clear with your scenario. Could you please try to describe in details the exact case, so I can be of further help. 

I am looking forward to your reply.
 
Greetings,
Stefan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Suderson
Top achievements
Rank 1
answered on 15 Aug 2011, 02:02 PM
Hi,

I've 100 rows in my grid with a numertic column. Say, I've selected from Row 1 to Row 10, which shows the sum of the selected value as a tool tip(With the help of your code).

When I mouse over the 100th row, (100th row has 20 as its value), it shows the sum of the Row 1 to Row 10 which i got previously.

What I need is, i want to get the tool tip with the SUM, only to the rows that are selected in the view. Otherwise it should show the tool tip only yo the row when the mouse hovber occured.

Is my scenario understandable now ??
0
Stefan
Telerik team
answered on 17 Aug 2011, 02:43 PM
Hello Suderson,

Thank you for the clarification.

In the attached sample, you can find the following functionality:
- Show tooltips only for the selected cells from the currently visible cells
- Calculate the sum from the currently selected and visible cells

Now if you select from Row 1 to Row 10 and all of the rows are visible, when you hover a selected cell it will show the sum of the visible cells. However, if you hover to Row 100 with the same rows selected, no tooltip will be shown. Tooltip will only be shown for the selected cells.

I hope you find this useful. Let me know if you need further assistance.
 
All the best,
Stefan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Tatyana
Top achievements
Rank 1
answered on 22 Oct 2014, 10:10 AM
Hi,
Need calculate values selected cells (ASP.NET) as in Excel and input sum in tooltip, for example. This may be done using RadGrid?
0
Stefan
Telerik team
answered on 23 Oct 2014, 06:53 AM
Hi Tatyana,

This forum concerns Telerik UI for WinForms, while your question seems to be related to Telerik UI for ASP.NET. Please address your question in the appropriate forum in order to get adequate assistance: http://www.telerik.com/forums/aspnet-ajax.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Suderson
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Suderson
Top achievements
Rank 1
Tatyana
Top achievements
Rank 1
Share this question
or