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

3 posts, 1 answers
  1. Ravin
    Ravin avatar
    16 posts
    Member since:
    Jun 2012

    Posted 04 May 2015 Link to this post

    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. Answer
    Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 05 May 2015 Link to this post

    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.

     
  3. DevCraft banner
  4. Ravin
    Ravin avatar
    16 posts
    Member since:
    Jun 2012

    Posted 05 May 2015 in reply to Kalin Link to this post

    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.

     

     

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

Back to Top