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

PivorGrid1

17 Answers 237 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Vivek
Top achievements
Rank 1
Vivek asked on 18 Sep 2015, 05:00 AM

How can i show the values of an item while double clicking on any of the value.

 

I mean is when we point our mouse pointer to an of the item in grid,then there will be a tooltip showing the current details of that item.How can i show it in message box while double clicking on it?

 

Can anyone help me Please...

17 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 18 Sep 2015, 11:50 AM
Hi Vivek,

Thank you for writing.

You can achieve the desired behavior by subscribing your RadPivotGrid instance to the MouseDoubleClick event and in the handler display a message box with the relevant information for the cell which is being clicked: 
private void radPivotGrid1_MouseDoubleClick(object sender, MouseEventArgs e)
{
    string res = string.Empty;
    RadPivotGrid grid = (RadPivotGrid)sender;
    LightVisualElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as LightVisualElement;
    if (cell != null)
    {
        if (cell is PivotCellElement)
        {
            PivotCellElement pivotCell = (PivotCellElement)cell;
            string caption = "Caption: " + pivotCell.AggregateDescription.DisplayName + "\n";
            string value = "Value: " + pivotCell.Text + "\n";
            string row = this.GetScreenTipValue(pivotCell.Row, "Row: ") + "\n";
            string col = this.GetScreenTipValue(pivotCell.Column, "Column: ") + "\n";
            res = caption + value + row + col;
        }
        else if (cell.ToolTipText != "")
        {
            res = cell.ToolTipText;
        }
        else if (cell is PivotGroupElement)
        {
            res = cell.Text;
        }
    }
 
    if (res != string.Empty)
    {
        MessageBox.Show(res);
    }
}
 
private string GetScreenTipValue(PivotGroupNode value, string prefix)
{
    IGroup group = value.Group;
    if (group != null)
    {
        List<IGroup> parents = new List<IGroup>();
        while (group != null)
        {
            parents.Add(group);
            group = group.Parent;
        }
        StringBuilder sb = new StringBuilder();
        sb.AppendFormat("{0}: ", prefix);
        int count = parents.Count;
        while (count > 0)
        {
            count--;
            if (count > 0)
            {
                sb.AppendFormat("{0} - ", parents[count].Name);
            }
            else
            {
                sb.AppendFormat("{0}", parents[count].Name);
            }
        }
 
        return sb.ToString();
    }
 
    return String.Empty;
}

I am also sending you a gif file showing the result on my end.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Vivek
Top achievements
Rank 1
answered on 19 Sep 2015, 04:59 AM

Hi Sir 

It really works.

 

Thankyou verymuch...

 

Can you do me a favour.. can you explain what you have done in the code.I'am not familar with some of codes like line5 and I'am new for telerik

0
Stefan
Telerik team
answered on 21 Sep 2015, 12:51 PM
Hi,

What this code does is the following. When the double click event occurs, according to the mouse location, we get the pivot cell element clicked. Then we build the string with the needed information and we use a message box to display it.

I hope that you find this information useful.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Deepak
Top achievements
Rank 1
answered on 23 Jun 2016, 12:08 PM

Hi Hristo,

Thank you for this post. This helped me lot.

One more thing i need is when i click on PivotGroupElement, can i get name of its RowGroupDescriptions ?

See in attached photo Please. If i click on "INV", in message box i want name "UserConstr".

Hope you will reply soon.

Thank you.

 

 

 

 

0
Hristo
Telerik team
answered on 23 Jun 2016, 01:10 PM
Hi Deepak,

Thank you for writing.

Please see below how I modified the handler of the MouseDoubleClick event. Basically, you would need to get the level of the group node and depending whether it is on a row or a column map it to the RowGroupDescriptions or ColumnGroupDescriptions collections. 
private void radPivotGrid1_MouseDoubleClick(object sender, MouseEventArgs e)
{
    string res = string.Empty;
    RadPivotGrid grid = (RadPivotGrid)sender;
    LightVisualElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as LightVisualElement;
    if (cell != null)
    {
        if (cell is PivotCellElement)
        {
            PivotCellElement pivotCell = (PivotCellElement)cell;
            string caption = "Caption: " + pivotCell.AggregateDescription.DisplayName + "\n";
            string value = "Value: " + pivotCell.Text + "\n";
            string row = this.GetScreenTipValue(pivotCell.Row, "Row: ") + "\n";
            string col = this.GetScreenTipValue(pivotCell.Column, "Column: ") + "\n";
            res = caption + value + row + col;
        }
        else if (cell.ToolTipText != "")
        {
            res = cell.ToolTipText;
        }
        else if (cell is PivotGroupElement)
        {
            PivotGroupNode groupNode = ((PivotGroupElement)cell).Data;
            int level = groupNode.Group.Level;
            string agg = string.Empty;
 
            if (level <= this.radPivotGrid1.RowGroupDescriptions.Count)
            {
                PropertyGroupDescription desc = null;
                if (groupNode.Axis == PivotAxis.Rows)
                {
                    desc = this.radPivotGrid1.RowGroupDescriptions[level] as PropertyGroupDescription;
                }
                else
                {
                    desc = this.radPivotGrid1.ColumnGroupDescriptions[level] as PropertyGroupDescription;
                }
                  
                if (desc != null)
                {
                    agg = desc.PropertyName;
                }
            }
 
            res = agg + "\n" + cell.Text;
        }
    }
 
    if (res != string.Empty)
    {
        MessageBox.Show(res);
    }
}

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
0
Deepak
Top achievements
Rank 1
answered on 24 Jun 2016, 06:37 AM

Hi Hristo,

Thank you sooooooo much. This is exactly what i wanted.

One more thing. Can we expand context menu ?

After 'Show Field List' in menu i want to add more options.
0
Hristo
Telerik team
answered on 24 Jun 2016, 08:03 AM
Hello Deepak,

Thank you for writing.

Yes, you can modify the context menu. For the purpose, you would need to inherit the PivotGridContextMenu class and depending on the context add your custom menu items: 
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
  
        MyPivotGridContextMenu menu = new MyPivotGridContextMenu(this.radPivotGrid1.PivotGridElement);
        this.radPivotGrid1.PivotGridElement.ContextMenu = menu;
    }
}
  
public class MyPivotGridContextMenu : PivotGridContextMenu
{
    public MyPivotGridContextMenu(RadPivotGridElement pivotGridElement)
        : base(pivotGridElement) { }
  
    protected override void AdjustItemsForContext()
    {
        base.AdjustItemsForContext();
  
        if (this.Context is PivotCellElement)
        {
            RadMenuItem customMenuItem = new RadMenuItem();
            customMenuItem.Text = "Export to Excel";
            RadMenuSeparatorItem separator = new RadMenuSeparatorItem();
            this.Items.Add(separator);
  
            customMenuItem.Click += customMenuItem_Click;
            this.Items.Add(customMenuItem);  
        }
    }
  
    private void customMenuItem_Click(object sender, EventArgs e)
    {
        RadMessageBox.Show("Exported!");
    }
}

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Deepak
Top achievements
Rank 1
answered on 27 Jun 2016, 07:33 AM

Thank you Hristo. You are a life saver.

 

0
Deepak
Top achievements
Rank 1
answered on 04 Jul 2016, 09:20 AM

Hi Hristo,

Is there any limitation to the number of rows we can see in pivot Grid ?

I am adding 14,50,000 into pivot grid but can't see any result.

0
Hristo
Telerik team
answered on 04 Jul 2016, 02:50 PM
Hello Deepak,

Thank you for writing. 

There is no limitation of the rows count in RadPivotGrid. In case you keep experiencing this issue please open up a support ticket and send us your project so that we can investigate it locally.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Deepak
Top achievements
Rank 1
answered on 29 Jul 2016, 07:20 AM

Hi,

I want to save the layout of PivotGrid whenever position of GroupDescription or AggregationDescription is changed.

Is there any event or method to do so ? I don't want to save layout on Button click.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Jul 2016, 12:12 PM
Hello Deepak,

Thank you for writing. 

You can subscribe to the PivotGridElement.GroupDescriptorElementCreating and PivotGridElement.AggregateDescriptorElementCreating events which are fired when you add row/column descriptors or aggregate descriptors. However, note that when you reorder the available row descriptors, for example, the event will be fired again for all available descriptors because the pivot grid data is reloaded.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Deepak
Top achievements
Rank 1
answered on 29 Jul 2016, 12:27 PM

Hello Dess,

Thank you for your prompt Reply.

I have checked these events. Problem with these events is my function will be called for each row/column/aggregate descriptors.

What i want is if i drag any descriptor and drop it in Row/Column/Filter area a function should be called only once.

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Aug 2016, 08:17 AM
Hello Deepak,

Thank you for writing back. 
  
You can handle the PivotGridElement.DragDropService. event which is fired just once. Thus, when you drag a certain row descriptor and drop it in the columns descriptors area, the pivot data will be regenerated, the mentioned event will be fired and you can execute the desired action.

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Deepak
Top achievements
Rank 1
answered on 03 Aug 2016, 04:47 AM

Thank you Dess. I think this will solve my problem. I will let you know if it doesn't help. 

 

Regards,

Deepak

0
Deepak
Top achievements
Rank 1
answered on 12 Aug 2016, 12:48 PM

Hello,

 

I want to check no of children in each Descriptor. Like in attached png file, i want Commodity Row descriptor should return 1 value.

Idea is on a button click i want Column/Row Group Descriptor who has only one children should be moved to Filter area.

0
Hristo
Telerik team
answered on 16 Aug 2016, 01:33 PM
Hi Deepak,

Thank you for writing.

You can get the unique group description for each of the rows by refreshing the values provider this way: 
List<object> distinctItems;
private void radButton_Click(object sender, EventArgs e)
{
    foreach (PropertyGroupDescriptionBase groupDescription in this.localDataProvider.RowGroupDescriptions)
    {
        DistinctValuesProvider valuesProvider = ((IDistinctValuesDescription)groupDescription).GetDisctinctValuesProvider();
        valuesProvider.Updated += new EventHandler<EventArgs>(ValuesProvider_Updated);
        valuesProvider.Refresh();
    }
}
 
private void ValuesProvider_Updated(object sender, EventArgs e)
{
    DistinctValuesProvider valuesProvider = sender as DistinctValuesProvider;
    valuesProvider.Updated -= this.ValuesProvider_Updated;
    this.distinctItems = new List<object>(valuesProvider.DisctinctValues);
}

Similarly, if you iterate the ColumnsGroupDescriptions collection you will get the unique column descriptions. 

I would like to also note that we try to keep our forum threads focused on a single topic. In case you need further assistance and your question is not related to the original one or an existing one elsewhere, please create a new thread or open up a support ticket.

I hope this information is useful.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Tags
PivotGrid and PivotFieldList
Asked by
Vivek
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Vivek
Top achievements
Rank 1
Stefan
Telerik team
Deepak
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or