Click events

5 posts, 0 answers
  1. Glen
    Glen avatar
    17 posts
    Member since:
    Aug 2010

    Posted 07 Nov 2013 Link to this post

    Hi, is it possible to add any kind of interaction events to the PivotGrid, for example right click menus on cells, or even a simple left click?
  2. rho
    rho avatar
    9 posts
    Member since:
    Feb 2006

    Posted 11 Nov 2013 Link to this post

    Please add this very usefull function.
    It's often requested to offer drill-down functions, which then would be possible.

    Thanks
  3. DevCraft banner
  4. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 12 Nov 2013 Link to this post

    Hello Glen,

    There are several ways to achieve the desired functionality. First one is to handle MouseLeftButtonUp (or MouseLeftButtonDown or any other Mouse event) and get the clicked element in the following way:
    var clickedElement = e.OriginalSource as FrameworkElement;
     
    if (clickedElement == null)
    {
        return;
    }
     
    var cellData = clickedElement.DataContext as CellData;
     
    if (cellData != null)
    {
        MessageBox.Show("Clicked element is: " + cellData.Data + " RowItem = " + cellData.RowItem + " ColumnItem " + cellData.ColumnItem);
    }

    You can also add RadContextMenu to RadPivotGrid which will be shown when you right click on the pivot:
    <pivot:RadPivotGrid x:Name="radPivotGrid" MouseLeftButtonUp="radPivotGrid_MouseLeftButtonUp"
                        CellTemplate="{StaticResource CustomCellTemplate}"
                        DataProvider="{StaticResource LocalDataProvider}">
        <telerik:RadContextMenu.ContextMenu>
            <telerik:RadContextMenu>
                <telerik:RadMenuItem Header="Item 1" />
            </telerik:RadContextMenu>
        </telerik:RadContextMenu.ContextMenu>
    </pivot:RadPivotGrid>

    And one more option - you can change RadPivotGrid's CellTemplate and put whatever element you need (for example HyperlinkButton).

    I've prepared a sample project demonstrating all of the above. Please give it a try and inform us in case you have any problems or concerns.

    Regards,
    Rosen Vladimirov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  5. Asuman
    Asuman avatar
    17 posts
    Member since:
    Dec 2014

    Posted 03 Jan in reply to Rosen Vladimirov Link to this post

    Hi Rosen,

    Thanks for sharing the solution. Can we get property names of the rows and columns  of the clicked cell?

  6. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 06 Jan Link to this post

    Hi Asuman,

    In the particular sample you can get the second level parent headers as shown below:

    var col = (cellData.ColumnItem as Telerik.Pivot.Core.IGroup).Parent.Name;
    var row = (cellData.RowItem as Telerik.Pivot.Core.IGroup).Parent.Name;

    Hope this helps.

    Regards,
    Kalin
    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
Back to Top
DevCraft banner