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

PivotGrid - Getting data from a cell (user click event)

2 Answers 44 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Ravin
Top achievements
Rank 1
Ravin asked on 04 May 2015, 04:21 PM

Hi,

 I have a user control with a RadPivotGrid, that has a MouseLeftButtonUp event to grab information for the current cell:

<UserControl ...>
    <Grid ...>
    <!-- ... //-->
    <pivot:RadPivotGrid x:Name="pivotGrid"  MouseLeftButtonUp="pivotGrid_MouseLeftButtonUp" ... />
    <!-- ... //-->
    </Grid>
</UserControl>

 In my *.cs file, I have the handler for the code:

private void pivotGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    var clickedElement = e.OriginalSource as FrameworkElement;
    if (clickedElement == null)
    {
        return;
    }
     
    var cellData = clickedElement.DataContext as CellData;
    if (cellData == null)
    {
        return;
    }
     
    //var ColumnItem = cellData.ColumnItem as Telerik.Pivot.Core.ViewModels.GroupNode;
    var ColumnItem = cellData.ColumnItem;
    //...
}

If I put "(Telerik.Pivot.Core.ViewModels.GroupNode)cellData.ColumnItem" in the "Watch" tab of the Debugger in Visual Studio 2012, I can see the properties for that class, and write ((Telerik.Pivot.Core.ViewModels.GroupNode)cellData.ColumnItem).Group, which gives me the object I want back; but if I try to write the cast in method body, I get an error saying "The type or namespace name 'GroupNode' does not exist in the namespace 'Telerik.Pivot.Core.ViewModels' (are you missing an assembly reference?)". In my references, I have Telerik.Pivot.Core 2014.1.224.1050. I don't see any other Telerik.Pivot.Core dlls to include in the project in my installation folder.

 

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Kalin
Telerik team
answered on 05 May 2015, 08:14 AM
Hello Ravin,

GroupNode is an internal class that implements the IGroup interface. You would need to cast it to IGroup in order to get the needed object:

var ColumnItem = cellData.ColumnItem as Telerik.Pivot.Core.IGroup;

Hope this helps.

Regards,
Kalin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Ravin
Top achievements
Rank 1
answered on 05 May 2015, 01:26 PM
[quote]Kalin said:Hello Ravin,

GroupNode is an internal class that implements the IGroup interface. You would need to cast it to IGroup in order to get the needed object:

var ColumnItem = cellData.ColumnItem as Telerik.Pivot.Core.IGroup;

Hope this helps.

Regards,
Kalin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 

[/quote]

 

Thank you, this solved the issue I had. :)

Tags
PivotGrid
Asked by
Ravin
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Ravin
Top achievements
Rank 1
Share this question
or