Hide nodes in FieldsControl

5 posts, 1 answers
  1. Eduard
    Eduard avatar
    7 posts
    Member since:
    Jul 2012

    Posted 15 Jan Link to this post

    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

  2. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 18 Jan Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Eduard
    Eduard avatar
    7 posts
    Member since:
    Jul 2012

    Posted 19 Jan in reply to Hristo Merdjanov Link to this post

    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

  5. Answer
    Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 19 Jan Link to this post

    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
  6. Eduard
    Eduard avatar
    7 posts
    Member since:
    Jul 2012

    Posted 19 Jan in reply to Hristo Merdjanov Link to this post

    Thank you Hristo,

     Now it works perfectly!

    Eduard

Back to Top
UI for WinForms is Visual Studio 2017 Ready