Hierarchy seems to not work correctly?

5 posts, 1 answers
  1. Jasper
    Jasper avatar
    3 posts
    Member since:
    Jul 2013

    Posted 08 Jul 2013 Link to this post

    Hey there,

    I've been looking around for ages and just can't seem to find anything that resembles the problem I have (Or I'm not looking for the right things). This is also why the title is so vague. I just don't know what's going wrong exactly

    I'm trying to build hierarchy in a grid. At first I tried to create one programmatically. That one ended up looking like the image attached. So, I thought, perhaps I ended up making an error, thus I tried creating the intended grid through the property builder. But that one too ended up looking like attached image.

    The designer code is as followed:
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class SetsForm
        Inherits Telerik.WinControls.UI.RadForm
        'Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
                If disposing AndAlso components IsNot Nothing Then
                End If
            End Try
        End Sub
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer. 
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Dim GridViewComboBoxColumn1 As Telerik.WinControls.UI.GridViewComboBoxColumn = New Telerik.WinControls.UI.GridViewComboBoxColumn()
            Dim GridViewTextBoxColumn1 As Telerik.WinControls.UI.GridViewTextBoxColumn = New Telerik.WinControls.UI.GridViewTextBoxColumn()
            Dim GridViewTextBoxColumn2 As Telerik.WinControls.UI.GridViewTextBoxColumn = New Telerik.WinControls.UI.GridViewTextBoxColumn()
            Dim GridViewTextBoxColumn3 As Telerik.WinControls.UI.GridViewTextBoxColumn = New Telerik.WinControls.UI.GridViewTextBoxColumn()
            Dim SortDescriptor1 As Telerik.WinControls.Data.SortDescriptor = New Telerik.WinControls.Data.SortDescriptor()
            Dim GridViewRelation1 As Telerik.WinControls.UI.GridViewRelation = New Telerik.WinControls.UI.GridViewRelation()
            Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(SetsForm))
            Dim GridViewTextBoxColumn4 As Telerik.WinControls.UI.GridViewTextBoxColumn = New Telerik.WinControls.UI.GridViewTextBoxColumn()
            Dim GridViewTextBoxColumn5 As Telerik.WinControls.UI.GridViewTextBoxColumn = New Telerik.WinControls.UI.GridViewTextBoxColumn()
            Dim GridViewTextBoxColumn6 As Telerik.WinControls.UI.GridViewTextBoxColumn = New Telerik.WinControls.UI.GridViewTextBoxColumn()
            Dim GridViewTextBoxColumn7 As Telerik.WinControls.UI.GridViewTextBoxColumn = New Telerik.WinControls.UI.GridViewTextBoxColumn()
            Me.RadGridView1 = New Telerik.WinControls.UI.RadGridView()
            Me.GridViewTemplate1 = New Telerik.WinControls.UI.GridViewTemplate()
            CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.RadGridView1.MasterTemplate, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.GridViewTemplate1, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.RadGridView1.AutoGenerateHierarchy = True
            Me.RadGridView1.BackColor = System.Drawing.Color.FromArgb(CType(CType(191, Byte), Integer), CType(CType(219, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.RadGridView1.Cursor = System.Windows.Forms.Cursors.Default
            Me.RadGridView1.Dock = System.Windows.Forms.DockStyle.Fill
            Me.RadGridView1.EnterKeyMode = Telerik.WinControls.UI.RadGridViewEnterKeyMode.EnterMovesToNextCell
            Me.RadGridView1.Font = New System.Drawing.Font("Segoe UI", 8.25!)
            Me.RadGridView1.ForeColor = System.Drawing.Color.Black
            Me.RadGridView1.ImeMode = System.Windows.Forms.ImeMode.NoControl
            Me.RadGridView1.Location = New System.Drawing.Point(0, 72)
            Me.RadGridView1.MasterTemplate.AllowColumnReorder = False
            Me.RadGridView1.MasterTemplate.AllowDragToGroup = False
            Me.RadGridView1.MasterTemplate.AutoGenerateColumns = False
            Me.RadGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
            GridViewComboBoxColumn1.AllowGroup = False
            GridViewComboBoxColumn1.EnableExpressionEditor = False
            GridViewComboBoxColumn1.FieldName = "ProductSet_CompanyID"
            GridViewComboBoxColumn1.HeaderText = "Bedrijf"
            GridViewComboBoxColumn1.Name = "ProductSet_CompanyID"
            GridViewComboBoxColumn1.Width = 93
            GridViewTextBoxColumn1.AllowGroup = False
            GridViewTextBoxColumn1.EnableExpressionEditor = False
            GridViewTextBoxColumn1.FieldName = "ProductSet_SetReference"
            GridViewTextBoxColumn1.HeaderText = "Set-Referentie"
            GridViewTextBoxColumn1.MaxLength = 50
            GridViewTextBoxColumn1.Name = "ProductSet_SetReference"
            GridViewTextBoxColumn1.Width = 139
            GridViewTextBoxColumn2.FieldName = "ProductSet_SetName"
            GridViewTextBoxColumn2.HeaderText = "Set-Naam"
            GridViewTextBoxColumn2.MaxLength = 255
            GridViewTextBoxColumn2.Name = "ProductSet_SetName"
            GridViewTextBoxColumn2.Width = 417
            GridViewTextBoxColumn3.FieldName = "ProductSet_ID"
            GridViewTextBoxColumn3.HeaderText = "column1"
            GridViewTextBoxColumn3.IsVisible = False
            GridViewTextBoxColumn3.Name = "ProductSet_ID"
            GridViewTextBoxColumn3.SortOrder = Telerik.WinControls.UI.RadSortOrder.Ascending
            GridViewTextBoxColumn3.Width = 47
            Me.RadGridView1.MasterTemplate.Columns.AddRange(New Telerik.WinControls.UI.GridViewDataColumn() {GridViewComboBoxColumn1, GridViewTextBoxColumn1, GridViewTextBoxColumn2, GridViewTextBoxColumn3})
            Me.RadGridView1.MasterTemplate.EnableFiltering = True
            Me.RadGridView1.MasterTemplate.EnableGrouping = False
            SortDescriptor1.PropertyName = "ProductSet_ID"
            Me.RadGridView1.MasterTemplate.SortDescriptors.AddRange(New Telerik.WinControls.Data.SortDescriptor() {SortDescriptor1})
            Me.RadGridView1.MasterTemplate.Templates.AddRange(New Telerik.WinControls.UI.GridViewTemplate() {Me.GridViewTemplate1})
            Me.RadGridView1.Name = "RadGridView1"
            GridViewRelation1.ChildColumnNames = CType(resources.GetObject("GridViewRelation1.ChildColumnNames"), System.Collections.Specialized.StringCollection)
            GridViewRelation1.ChildTemplate = Me.GridViewTemplate1
            GridViewRelation1.ParentColumnNames = CType(resources.GetObject("GridViewRelation1.ParentColumnNames"), System.Collections.Specialized.StringCollection)
            GridViewRelation1.ParentTemplate = Me.RadGridView1.MasterTemplate
            GridViewRelation1.RelationName = "SetProductRelation"
            Me.RadGridView1.Relations.AddRange(New Telerik.WinControls.UI.GridViewRelation() {GridViewRelation1})
            Me.RadGridView1.RightToLeft = System.Windows.Forms.RightToLeft.No
            Me.RadGridView1.ShowGroupPanel = False
            Me.RadGridView1.Size = New System.Drawing.Size(668, 313)
            Me.RadGridView1.TabIndex = 0
            Me.RadGridView1.Text = "3"
            Me.RadGridView1.UseScrollbarsInHierarchy = True
            Me.GridViewTemplate1.AutoGenerateColumns = False
            Me.GridViewTemplate1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
            GridViewTextBoxColumn4.FieldName = "ProductSetProduct_ID"
            GridViewTextBoxColumn4.HeaderText = "ID"
            GridViewTextBoxColumn4.Name = "ProductSetProduct_ID"
            GridViewTextBoxColumn5.FieldName = "ProductSetProduct_SetID"
            GridViewTextBoxColumn5.HeaderText = "SetID"
            GridViewTextBoxColumn5.IsVisible = False
            GridViewTextBoxColumn5.Name = "ProductSetProduct_SetID"
            GridViewTextBoxColumn6.FieldName = "ProductSetProduct_ProductReference"
            GridViewTextBoxColumn6.HeaderText = "Product-Reference"
            GridViewTextBoxColumn6.MaxLength = 50
            GridViewTextBoxColumn6.Name = "ProductSetProduct_ProductReference"
            GridViewTextBoxColumn7.FieldName = "ProductSetProduct_ProductName"
            GridViewTextBoxColumn7.HeaderText = "Product-Naam"
            GridViewTextBoxColumn7.MaxLength = 255
            GridViewTextBoxColumn7.Name = "ProductSetProduct_ProductName"
            Me.GridViewTemplate1.Columns.AddRange(New Telerik.WinControls.UI.GridViewDataColumn() {GridViewTextBoxColumn4, GridViewTextBoxColumn5, GridViewTextBoxColumn6, GridViewTextBoxColumn7})
            Me.GridViewTemplate1.EnableFiltering = True
            Me.GridViewTemplate1.EnableGrouping = False
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(668, 385)
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow
            Me.Name = "SetsForm"
            Me.RootElement.ApplyShapeToControl = True
            Me.Text = "Sets"
            CType(Me.RadGridView1.MasterTemplate, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.GridViewTemplate1, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
        End Sub
        Friend WithEvents RadGridView1 As Telerik.WinControls.UI.RadGridView
        Friend WithEvents GridViewTemplate1 As Telerik.WinControls.UI.GridViewTemplate
    End Class

    Any ideas as to why this is happening? I use version 2013.1.321.40 of the telerik components

    Thanks in advance,


    EDIT: Of course, I should state as to what's wrong of course...
    I expected the columns of the second level to be
    - ID
    - Product-Reference
    - Product-Naam

    And the last column just 'not be there'
  2. Ivan Petrov
    Ivan Petrov avatar
    718 posts

    Posted 11 Jul 2013 Link to this post

    Hello Jasper,

    Thank you for writing.

    I copied your code to a form, run the project and everything on my machine worked as expected. Please, refer to the attached screenshot. If you are still experiencing the issue I would kindly ask you to send me your project so I can investigate the issue further and provide you with accurate support.

    Looking forward to your reply.

    Ivan Petrov
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Jasper
    Jasper avatar
    3 posts
    Member since:
    Jul 2013

    Posted 15 Jul 2013 Link to this post

    Hey there Ivan,

    I cannot submit a support ticket it seems, because we have not purchased the product under this login.

    To give some extra information instead: I'm using entity framework - entities as datasource in my project. So with my original post in mind, this is the code behind the form
    Imports Telerik.WinControls.UI
    Public Class SetsForm
        Private DHDataContext As New DHSetsEntities
        Protected Sub Form_Load() Handles Me.Load
            CType(RadGridView1.Columns("ProductSet_CompanyID"), GridViewComboBoxColumn).DataSource = DHDataContext.companies.OrderBy(Function(o) o.name)
            CType(RadGridView1.Columns("ProductSet_CompanyID"), GridViewComboBoxColumn).ValueMember = "Company_ID"
            CType(RadGridView1.Columns("ProductSet_CompanyID"), GridViewComboBoxColumn).DisplayMember = "Name"
            CType(RadGridView1.Columns("ProductSet_CompanyID"), GridViewComboBoxColumn).FieldName = "ProductSet_CompanyID"
            RadGridView1.DataSource = DHDataContext.ProductSets
            RadGridView1.Templates(0).DataSource = DHDataContext.ProductSetsProducts
        End Sub
        Private Sub RadButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton1.Click
            If MsgBox("Weet u zeker dat u de aanpassingen wilt opslaan?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                    MsgBox("Aanpassingen zijn opgeslagen.")
                Catch ex As OptimisticConcurrencyException
                    DHDataContext.Refresh(Objects.RefreshMode.ClientWins, DHDataContext.ProductSetsProducts)
                    DHDataContext.Refresh(Objects.RefreshMode.ClientWins, DHDataContext.ProductSets)
                    MsgBox("Aanpassingen zijn opgeslagen.")
                Catch ex As Exception
                    MsgBox("Kan aanpassingen niet opslaan. Geef het volgende door aan de helpdesk: " & vbCrLf & vbCrLf & _
                           ex.Message & vbCrLf & ex.StackTrace)
                End Try
        End Sub
        Private Sub RadButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton2.Click
            DHDataContext.Refresh(Objects.RefreshMode.StoreWins, DHDataContext.ProductSetsProducts)
            DHDataContext.Refresh(Objects.RefreshMode.StoreWins, DHDataContext.ProductSets)
        End Sub
    End Class

    Entities configured as in image attached.
    A 'ProductSets' can have multiple 'ProductSetsProducts', with 'ProductSetProduct_SetID' as foreign key. The navigation properties seem to be the extra column that I never defined.

    Until now I've been trying to just work around it by configuring the columns after the DataBindingComplete-event. The column with the navigation properties, however, doesn't seem to be adjustable through this method.

    If it's not possible to help me in this way, I'll make a ticket under our general account

    Thanks in advance,


  4. Answer
    Ivan Petrov
    Ivan Petrov avatar
    718 posts

    Posted 18 Jul 2013 Link to this post

    Hello Jasper,

    Thank you for writing back.

    Before getting to your questions I would like to clarify something. In order to continue to receive uninterrupted support services you will have to post tickets from the account that has purchased the license. Alternatively you can add this account as a License Developer to the license. You can find more information on License developers here.

    On your question, I recreated your whole setup with the database and the entity framework. This allowed me to reproduce the issue and to find the reason for it. You can resolve it by setting the AutoGenerateHierarchy property of the grid to False.

    Here is what happens in your case. You set up the master and child template, add columns, tweak settings etc. Then when you set the datasource to the grid, because it is setup to auto-generate the hierarchy it clears all its child templates and generates new one (as your hierarchy has two levels). Then you set the datasource to the first child template. This template though is not the one you created but the one generated by the grid, hence none of your settings are preserved.

    I hope this will help. Do not hesitate to contact the Telerik support again.

    Ivan Petrov
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  5. Jasper
    Jasper avatar
    3 posts
    Member since:
    Jul 2013

    Posted 19 Jul 2013 Link to this post

    Hey there Ivan,

    Thank you for replying. This indeed solved my problem.

    I shall add this account as license developer.

    Thank you again for your time

Back to Top