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

Hide nodes in FieldsControl

6 Answers 92 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Eduard
Top achievements
Rank 1
Eduard asked on 15 Jan 2016, 10:05 AM

Hello,

 I'm using a PivotGrid with nodes from a database. I want to hide some of the fields of the fieldControl and I use this code:

Private Sub RadPivotFieldList1_NodeFormatting(ByVal sender As Object, ByVal e As TreeNodeFormattingEventArgs)
        If e.Node.Text = "IdAnalisis" Then
            e.Node.Visible = False
        End If

The problem is that when it shows the dialog, the IdAnalisis node is still there and when I press the FieldsControl window, then it disappears. I tried to use refresh and invalidate in different parts of the code, but always the same problem. Any solution?

Thank you,

Eduard

6 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 18 Jan 2016, 04:19 PM
Hi Eduard,

Thank you for writing.

The easiest solution would be to work with a LocalDataSourceFieldDescriptionsProvider and handle its AddingContainerNode event. Then you would be able to set the AutoGenerateField flag to false for selected fields.

I am sending you attached a sample project which I believe should get you going.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Eduard
Top achievements
Rank 1
answered on 19 Jan 2016, 07:37 AM

Hi Hristo,

Thank you for your answer, but is not possible to do use the database directly (without using LocalDataSource)? Our database has a lot of columns and I will need extra work to use as LocalDataSource... I just use this:

Me.V_ResultsTableAdapter.Fill(Me.V_Results._V_Results)
RadPivotGrid1.DataSource = VResultsBindingSource

Where V_Results is a view of SQL server.

Thanks,

Eduard

0
Accepted
Hristo
Telerik team
answered on 19 Jan 2016, 01:42 PM
Hello Eduard,

Thank you for writing back.

The RadPivotFieldList control internally contains a tree which can be accessed and from there selected nodes can be hidden. For you type of scenario, it is suitable to subscribe the pivot control to the UpdateComplete event and in the handler iterate the field list nodes and hide those nodes which you do not want to be visible:
Private Sub RadPivotGrid1_UpdateCompleted(sender As Object, e As EventArgs)
    Dim dateNode As RadTreeNode = Me.RadPivotFieldList1.FieldsControl.Nodes.Where(Function(n) n.Text = "Date").FirstOrDefault()
    If dateNode IsNot Nothing Then
        Dim weekNode = dateNode.Nodes.Where(Function(n) n.Text = "Week").FirstOrDefault()
        If weekNode IsNot Nothing Then
            weekNode.Visible = False
        End If
 
    End If
End Sub

I hope this information is useful. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Eduard
Top achievements
Rank 1
answered on 19 Jan 2016, 03:53 PM

Thank you Hristo,

 Now it works perfectly!

Eduard

0
Michael
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 13 Oct 2020, 10:58 AM

I realize this is coming years after the original post, but I'm trying to weed out some of the fields from my PivotFieldList and came across this thread.  I downloaded your example and it runs fine, but when I copy some of its code -- practically word-for-word -- into my application, it never hits the handler.  Here's what I have:

    Protected Overrides Sub OnLoad(e As EventArgs)
        MyBase.OnLoad(e)

        Dim dao = New InvoiceDaoImpl() With {.Session = session}
        Dim details = dao.LoadFromSql(makeQuery(), take)
        Me.provider = New LocalDataSourceProvider() With {.ItemsSource = details.ToList()}
        Dim descriptionProvider As LocalDataSourceFieldDescriptionsProvider = New LocalDataSourceFieldDescriptionsProvider()

        AddHandler descriptionProvider.AddingContainerNode, AddressOf descriptionProvider_AddingContainerNode

        Me.provider.FieldDescriptionsProvider = descriptionProvider
    End Sub

    Private Sub descriptionProvider_AddingContainerNode(sender As Object, e As ContainerNodeEventArgs)
        If e.ContainerNode.Name = "Promotion" Then
            Dim fin As FieldInfoNode = TryCast(e.ContainerNode, FieldInfoNode)
            TryCast(fin.FieldInfo, PropertyFieldInfo).AutoGenerateField = False
        End If
    End Sub

The only difference is that rather than using your list of Orders as the data-source I'm using my list "details".  I've checked and the list has data, and of course it has many public properties.

What can be causing this?  I see that your example program is using the Telerik Winforms packages installed on my system, whereas mine is using a recent NuGet version of your packages, but it seems unlikely that that would cause this.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Oct 2020, 01:31 PM

Hello, Michael,  

I have tested the provided sample project by Hristo and it works as expected. The "Promotion" field is not displayed in the RadPivotFieldList

Please have in mind that it is important to subscribe to the LocalDataSourceFieldDescriptionsProvider.AddingContainerNode event before the descriptions are added to the provider and before it is being set to the RadPivotGrid.PivotGridElement.DataProvider. If you subscribe to this event at a later moment, the fields will be generated and the tree view in the field list will be populated will all properties.

In case you are still experiencing any further difficulties, it would be greatly appreciated if you can submit a support ticket from your Telerik account and provide a sample project demonstrating the undesired behavior that you are facing. Thus, we would be able to investigate the precise case and provide further assistance. Thank you in advance for your cooperation.
 
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
PivotGrid and PivotFieldList
Asked by
Eduard
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Eduard
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Iron
Iron
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or