We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I hide a row column in a pivotgrid

Thread ID:

Created:

Updated:

Platform:

Replies:

146441 Aug 3,2019 08:19 PM UTC Aug 19,2019 01:48 PM UTC WinForms 3
loading
Tags: PivotGridControl
George Busby
Asked On August 3, 2019 08:19 PM UTC

I want to be able to get to the recordsource row for the current row. The best way to get the correct row is to use the Record ID property so I want to add that as a row column in the PivotGrid but I do not want the column to be displayed to the user.. Is there a way to set a row column to a property from the recordsource but not display the column to the user?

If this is not possible, is there another way to do this besides taking the values of all of the the row columns and doing a search in the recordsource for the corresponding row. This will not work for my situation in all cases, I do not have enough columns to always make the query unique, that is why I want to use the record ID property.

Subburaj Pandian Veluchamy [Syncfusion]
Replied On August 5, 2019 12:24 PM UTC

Hi George,

We have analyzed the reported query “How to hide the row column in pivot grid”. You can hide the rows/columns of pivot grid control by using the RowHeights and ColWidths properties which is available in GridModel class. If you want to hide the row column values, you should set the ShowGroupBar value as false to avoid the overlapping between group bar and pivot grid control.
 
 
Please refer the following code sample, 
 
# Form1.vb 
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 
  
        Me.PivotGridControl1.ShowGroupBar = False 
        Me.PivotGridControl1.EnableValueEditing = True 
  
AddHandler PivotGridControl1.TableControl.GroupDropArea.ColWidthsChanged,AddressOf GroupDropArea_ColWidthsChanged
       'to hide the second column. 
        PivotGridControl1.TableModel.ColWidths(2) = 0 
   End Sub

    'To maintain the column width value as 0 after performing any drag and drop operation. 
    Private Sub GroupDropArea_ColWidthsChanged(ByVal sender As ObjectByVal e AsSyncfusion.Windows.Forms.Grid.GridRowColSizeChangedEventArgs) 
  
        PivotGridControl1.TableModel.ColWidths(2) = 0 
  
    End Sub 

If it doesn’t meet your actual requirement, could you please share the detailed description about your requirement along with screenshots, so that it could be helpful to provide the solution at the earliest. 
 
Regards,
Subburaj Pandian V  


George Busby
Replied On August 17, 2019 12:32 PM UTC

Thanks, That hid the column. However, it did not hide the header for the column. Is there also a command to hide the column header that is associated with the column?

Thirupathi Bala Krishnan [Syncfusion]
Replied On August 19, 2019 01:48 PM UTC

Hi George,

Thanks for the update.

We have analyzed the reported query –“How to hide the group bar column headers when corresponding column width value is 0”. You can achieve this requirement by changing the value of RowGroupDropArea property.  Also set the group bar item column width value based on the pivot grid column width.

Please refer the following code sample.

 
# Form1.vb

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load         
 
        'to hide the second column. 
        PivotGridControl1.TableModel.ColWidths(2) = 0 
 
        AddHandler PivotGridControl1.TableControl.GroupDropArea.ColWidthsChanged, AddressOf GroupDropArea_ColWidthsChanged 
        AddHandler Me.PivotGridControl1.TableModel.ColWidthsChanged, AddressOf TableModel_ColWidthsChanged 
 
        'Resize the elements in row grouping bar. 
        Dim emptySpaceWidth As Integer = 6 
        Dim index As Integer 
        For j As Integer = 1 To 2 * (PivotGridControl1.TableControl.PivotRows.Count) 
            If j Mod 2 = 0 AndAlso PivotGridControl1.TableControl.RowGroupDropArea IsNot Nothing AndAlso PivotGridControl1.TableControl.RowGroupDropArea.Model IsNot Nothing Then 
                index = j / 2 
                PivotGridControl1.TableControl.RowGroupDropArea.Model.ColWidths(j) = If(PivotGridControl1.TableModel.ColWidths(index) = 0, 0, PivotGridControl1.TableModel.ColWidths(index) - (emptySpaceWidth + emptySpaceWidth / 2)) 
            End If 
        Next 
 
        'Resize the entire row group bar width. 
        Dim width As Integer = 0 
        For i As Integer = 0 To PivotGridControl1.PivotRows.Count - 1 
            width += PivotGridControl1.TableModel.ColWidths(i) 
        Next 
        PivotGridControl1.TableControl.RowGroupDropArea.Width = width 
 
    End Sub 
 

Sample link : https://www.syncfusion.com/downloads/support/forum/146441/ze/WindowsApp11175839624

If the above solution does not resolve your actual requirement, could you please share the detailed description so that it could be helpful to provide the solution at the earliest.

Regards,
Thirupathi B.
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon