PivorGrid1

18 posts, 1 answers
  1. Vivek
    Vivek avatar
    5 posts
    Member since:
    Aug 2015

    Posted 18 Sep 2015 Link to this post

    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...

  2. Answer
    Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 18 Sep 2015 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Vivek
    Vivek avatar
    5 posts
    Member since:
    Aug 2015

    Posted 18 Sep 2015 in reply to Hristo Merdjanov Link to this post

    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

  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 21 Sep 2015 Link to this post

    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
  6. Deepak
    Deepak avatar
    10 posts
    Member since:
    May 2016

    Posted 23 Jun in reply to Hristo Merdjanov Link to this post

    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.

     

     

     

     

  7. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 23 Jun Link to this post

    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.
  8. Deepak
    Deepak avatar
    10 posts
    Member since:
    May 2016

    Posted 24 Jun in reply to Hristo Merdjanov Link to this post

    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.
  9. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 24 Jun Link to this post

    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.
  10. Deepak
    Deepak avatar
    10 posts
    Member since:
    May 2016

    Posted 27 Jun in reply to Hristo Merdjanov Link to this post

    Thank you Hristo. You are a life saver.

     

  11. Deepak
    Deepak avatar
    10 posts
    Member since:
    May 2016

    Posted 04 Jul in reply to Deepak Link to this post

    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.

  12. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 04 Jul Link to this post

    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.
  13. Deepak
    Deepak avatar
    10 posts
    Member since:
    May 2016

    Posted 29 Jul Link to this post

    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.

  14. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 29 Jul Link to this post

    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.
  15. Deepak
    Deepak avatar
    10 posts
    Member since:
    May 2016

    Posted 29 Jul in reply to Dess Link to this post

    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.

     

  16. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 02 Aug Link to this post

    Hello Deepak,

    Thank you for writing back. 
      
    You can handle the PivotGridElement.DragDropService.Stopped 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.
  17. Deepak
    Deepak avatar
    10 posts
    Member since:
    May 2016

    Posted 02 Aug in reply to Dess Link to this post

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

     

    Regards,

    Deepak

  18. Deepak
    Deepak avatar
    10 posts
    Member since:
    May 2016

    Posted 12 Aug Link to this post

    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.

  19. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 16 Aug Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready