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

Click events

4 Answers 80 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Glen
Top achievements
Rank 1
Glen asked on 07 Nov 2013, 03:53 PM
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?

4 Answers, 1 is accepted

Sort by
0
rho
Top achievements
Rank 1
answered on 11 Nov 2013, 03:53 PM
Please add this very usefull function.
It's often requested to offer drill-down functions, which then would be possible.

Thanks
0
Rosen Vladimirov
Telerik team
answered on 12 Nov 2013, 10:43 AM
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 >>
0
Asuman
Top achievements
Rank 1
answered on 03 Jan 2016, 12:05 PM

Hi Rosen,

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

0
Kalin
Telerik team
answered on 06 Jan 2016, 09:44 AM
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
Tags
PivotGrid
Asked by
Glen
Top achievements
Rank 1
Answers by
rho
Top achievements
Rank 1
Rosen Vladimirov
Telerik team
Asuman
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or