Search code examples
c#winformsdevexpresspivotdevexpress-windows-ui

how to find column, row and data area values from cell object in Devex Pivot grid


I am using Dev ex pivot grid to show some data on the screen. When user click on any cell in data area, I want to find out it's corresponding row, column and data area value and their field name.

I am handling CellClick event of devex pivot grid. with PivotCellEventArgs object I can find fieldname but not value.

I want the name and value for given cell from all perspectives (row, column and data area).

Thanks in advance.


Solution

  • In Razor MVC you can do that

    @Html.DevExpress().PivotGrid(settings =>
    {
        settings.Name = "PivotGrid";
        settings.CallbackRouteValues = new { Controller = "Home", Action = "PivotGridPartial" };
    
        settings.ClientSideEvents.CellClick = @"
        function(s,e){
            var EventArgs=e; 
            console.log(EventArgs.RowValue);
            console.log(EventArgs.RowFieldName);
            console.log(EventArgs.ColumnValue);
            console.log(EventArgs.ColumnFieldName);
            console.log(EventArgs.Value); 
        }";
    
        settings.Fields.Add(field =>
        {
            field.Area = PivotArea.RowArea;
            ...
        });
    
        settings.Fields.Add(field =>
        {
            field.Area = PivotArea.ColumnArea;
            ...
        });
    
        settings.Fields.Add(field =>
        {
            field.Area = PivotArea.DataArea;
            ...
        });
    
    }).Bind(Model).GetHtml()