Clickable Link on PivotGrid

0 Answers 47 Views
PivotGrid
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Rakhee asked on 28 Sep 2023, 09:00 AM | edited on 03 Oct 2023, 07:49 AM

Hi 

I have created a TelerikPivotGrid which displays a count of record per department and Type.

The data in the cell within the grid is clickable, and when a user clicks on I need to get the name of the column and name of the row for the cell they have clicked on.

Please can anyone advise how to get the values of the grid when a user clicks on the cell within the grid?

Thank you

Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
commented on 28 Sep 2023, 09:12 AM | edited

im not sure how to get the value of the column header title and the row title once the user clicks on the link?

Doncho
Telerik team
commented on 03 Oct 2023, 08:35 AM

Hi Rakhee,

I am afraid that there is no built-in API for this purpose in RadPivotGrid. What you can possibly do is use some native JavaScript (and/or jQuery) to reach the desired DOM elements and read the text inside.

Here's an example that can serve as a starting point:

function OnCellClick(sender, args) {
    var cellType = args.get_cellType();
    var cell = args.get_cell();
    var cellIndex = cell.cellIndex;
    var $dataZoneTable = $(cell).closest('.rpgTable');
    
    if (cellType == Telerik.Web.UI.PivotGridCellType.DataCell) {
        var $columnHeaderCell = $dataZoneTable.find('thead th').eq(cellIndex);
        var columnHeaderName = $columnHeaderCell.text(); // This will return "RFQ Number"
    }
    else if (cellType == Telerik.Web.UI.PivotGridCellType.RowHeaderCell) {
        var rowHeaderName = $dataZoneTable.find('.rpgRowsZone').eq(cellIndex).text();
    }
}

Please note that the specific logic and selectors in this example depend on your PivotGrid's configuration and content. You may need to make adjustments to the code accordingly.

If you find any additional functionality missing or have other feature requests, we encourage you to log them into our feedback portal. Your feedback is valuable to us, and it helps us improve our products to better meet your needs. You can access the Feedback portal here.

Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
commented on 03 Oct 2023, 09:32 AM

Hi Doncho

Thank you. Can you advise what the 'thead th' and '.rpgRowsZone' is a reference to?

 

This is my grid

<telerik:RadPivotGrid RenderMode="Lightweight" Height="700px"
                    ID="rpgCallSummary" runat="server">
                    <Fields>
                        <telerik:PivotGridRowField DataField="Department" ZoneIndex="0">
                        </telerik:PivotGridRowField>
                        <telerik:PivotGridColumnField DataField="CallType"></telerik:PivotGridColumnField>
                        <telerik:PivotGridAggregateField DataField="CallNumber" Aggregate="Count">
                            <CellTemplate>
                                <asp:LinkButton ID="lnkCallDetails" runat="server" OnClick="lnkCallDetails_Click" Text='<%# GetDataItem() %>'></asp:LinkButton>
                            </CellTemplate>
                        </telerik:PivotGridAggregateField>
                    </Fields>
                </telerik:RadPivotGrid>
Doncho
Telerik team
commented on 06 Oct 2023, 08:21 AM

Hi Rakhee,

The strings in question are native jQuery selectors for getting a reference to certain DOM elements on the page. The ones I shared are just examples on how column and row header cell could be accessed. Yet, the same selectors would work with specific PivotGrid configuration, and they should be modified as per the specific scenario.

Please keep in mind that the main purpose of the RadPivotGrid is to visualize and summarize data of your choice. It rather uses the calculated values from the data fields to build various reports to display and highlight the desired information. Its intentions are not to modify data or execute CRUD operations.

That said, accessing data items, header, cell, rows etc. is a specialty of the RadGrid control and is not supported by the RadPivotGrid control. 

You can check the following resource for additional info about the RadPivotGrid purpose and functionality:
https://www.telerik.com/blogs/aspnet-pivot-table-made-easy

Also, you can check these posts for its differences with RadGrid:
https://www.telerik.com/forums/getting-access-to-strongly-typed-object-that-i%27ve-bound-the-pivotgrid-to#jxWdB_kWmkSoMCDwSiVj_g
https://www.telerik.com/forums/template-column-for-pivot-grid#ro_LCNv1N0GIQ46Jj0413w
https://www.telerik.com/forums/compare-cell-value-to-his-grand-total#fKkrL5GUaEenSX4wWTc7wg

No answers yet. Maybe you can help?

Tags
PivotGrid
Asked by
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or