View definition and hierarchical grid

11 posts, 0 answers
  1. Antonio Ibáñez Oliva
    Antonio Ibáñez Oliva avatar
    13 posts
    Member since:
    Aug 2012

    Posted 04 Jul 2012 Link to this post

    Hi, is possible to use a hierarchical grid and define custom columns groups? I've tried but the the hierarchy does not appear, i mean, the records appears in "plain" mode.

    Thanks
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 09 Jul 2012 Link to this post

    Hello Antonio,

    Thank you for writing.

    You can have Column groups view together with hierarchy. The view definition is just a layout describing how the data should be represented by the UI and has nothing to do with the actual data structure. Please, refer to the attached example project where I have demonstrated how to achieve this.

    I hope this will be useful. Should you have further questions, feel free to write back.
     
    Greetings,
    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Antonio Ibáñez Oliva
    Antonio Ibáñez Oliva avatar
    13 posts
    Member since:
    Aug 2012

    Posted 17 Jul 2012 Link to this post

    Hi Ivan, your sample works, but mine is quite different. All the records are in the same table and the relation is a self-referenced one. See my code:

    Me.dgDatos.Relations.AddSelfReference(Me.dgDatos.MasterTemplate, "NUM", "IDSUP")
    Me.dgDatos.MasterTemplate.ExpandAll()
     
     
    Dim view As New ColumnGroupsViewDefinition()
    view.ColumnGroups.Add(New GridViewColumnGroup("PROYECTO"))
    view.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow())
    view.ColumnGroups(0).Rows(0).Columns.Add(Me.dgDatos.Columns("CODIGO"))
    view.ColumnGroups(0).Rows(0).Columns.Add(Me.dgDatos.Columns("ORDEN"))
    view.ColumnGroups(0).Rows(0).Columns.Add(Me.dgDatos.Columns("UD"))
    view.ColumnGroups(0).Rows(0).Columns.Add(Me.dgDatos.Columns("RESUMEN"))
    view.ColumnGroups(0).Rows(0).Columns.Add(Me.dgDatos.Columns("CANPRES"))
    view.ColumnGroups(0).Rows(0).Columns.Add(Me.dgDatos.Columns("PRECIO"))
    view.ColumnGroups(0).Rows(0).Columns.Add(Me.dgDatos.Columns("TOTAL_PROYECTO"))
    view.ColumnGroups.Add(New GridViewColumnGroup("CERTIFICADO A ORIGEN"))
    view.ColumnGroups(1).Rows.Add(New GridViewColumnGroupRow())
    view.ColumnGroups(1).Rows(0).Columns.Add(Me.dgDatos.Columns("MEDICION_ORIGEN"))
    view.ColumnGroups(1).Rows(0).Columns.Add(Me.dgDatos.Columns("IMPORTE_ORIGEN"))
    view.ColumnGroups(1).Rows(0).Columns.Add(Me.dgDatos.Columns("PORC_ORIGEN"))
    view.ColumnGroups.Add(New GridViewColumnGroup("CERTIFICACIÓN ACTUAL"))
    view.ColumnGroups(2).Rows.Add(New GridViewColumnGroupRow())
    view.ColumnGroups(2).Rows(0).Columns.Add(Me.dgDatos.Columns("MEDICION_ACTUAL"))
    view.ColumnGroups(2).Rows(0).Columns.Add(Me.dgDatos.Columns("IMPORTE_ACTUAL"))
    view.ColumnGroups(2).Rows(0).Columns.Add(Me.dgDatos.Columns("PORC_ACTUAL"))
    view.ColumnGroups.Add(New GridViewColumnGroup("PENDIENTE POR CERTIFICAR"))
    view.ColumnGroups(3).Rows.Add(New GridViewColumnGroupRow())
    view.ColumnGroups(3).Rows(0).Columns.Add(Me.dgDatos.Columns("MEDICION_PDTE"))
    view.ColumnGroups(3).Rows(0).Columns.Add(Me.dgDatos.Columns("IMPORTE_PDTE"))
    view.ColumnGroups(3).Rows(0).Columns.Add(Me.dgDatos.Columns("PORC_PDTE"))
    view.ColumnGroups.Add(New GridViewColumnGroup("DESGLOSE"))
    view.ColumnGroups(4).Rows.Add(New GridViewColumnGroupRow())
    view.ColumnGroups(4).Rows(0).Columns.Add(Me.dgDatos.Columns("DESGLOSE"))
     
    dgDatos.ViewDefinition = view

  5. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 20 Jul 2012 Link to this post

    Hello Antonio,

    Thank you for writing back.

    The self-reference hierarchy currently works only with TableViewDefinition. The self-reference hierarchy should work with all view definitions and this is a missing feature. I have added a feature request to our Public Issue Tracking System - PITS. You can subscribe to track its status and add your vote/comment for it on the following link - PITS Feature.

    I have also updated your Telerik points for the suggestion.

    If you have further questions, do not hesitate to write back.
     
    Regards,
    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  6. Jay
    Jay avatar
    7 posts
    Member since:
    Oct 2009

    Posted 22 Aug 2014 in reply to Ivan Petrov Link to this post

    Any news on this? The bug still remains with the latest release.
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Aug 2014 Link to this post

    Hello Dimple,

    This feature is not yet implemented. Here is the link to the migrated item in our new feedback portal: http://feedback.telerik.com/Project/154/Feedback/Details/110568.

    Regards,
    Stefan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  8. Carlos
    Carlos avatar
    4 posts
    Member since:
    Apr 2016

    Posted 07 Apr Link to this post

    Good morning,

            To change the display clustered column you must use 'ColumnGroupsViewDefinition' and not 'TableViewDefinition' which is the default one. You set as you indicate the viewDefinition and the refence, in my case, i use this order:

    myRadGridView.ViewDefinition = myColumnGroupsViewDefinition
     
    myRadGridView.Relations.AddSelfReference(myRadGridView.MasterTemplate, COLUMNA_ID, COLUMNA_IDPARENT);

     

             The relationship really does work, just that you do not see and does not give the user the ability to deploy the row. The simply catch the CellClick event:

    private void grdDatos_CellClick(object sender, GridViewCellEventArgs e)
    {
        if (GridColumnGroup_RowEsEpigrafe_ColumnNombre(e))
        {
            e.Row.IsExpanded = !e.Row.IsExpanded;
        }
    }
     
    private bool GridColumnGroup_RowEsEpigrafe_ColumnNombre(GridViewCellEventArgsBase e)
    {
        return myRadGridView.ViewDefinition is ColumnGroupsViewDefinition
               && e.Column.Name == COLUMNA_NAME
               && e.Row.Index > -1
               && e.Row.HierarchyLevel == 0;
    }

            My case is more complex because sometimes I have to group columns, and others are not; using the same grid. But it is a matter of making checks. I have tried to simplify it to get the idea. And if you want it perfect can use the 'CellFormatting' event to place the triangule image:

    void grdDatos_CellFormatting(object sender, CellFormattingEventArgs e)
    {
            var insertImage = GridColumnGroup_RowEsEpigrafe_ColumnNombre(e);
            if (insertImage)
            {
                if (myRadGridView.Rows[e.Row.Index].ChildRows.Any())
                {
                    e.CellElement.Image = e.Row.IsExpanded ? Resources.ExpandTrue : Resources.ExpandFalse;
                }
                else
                {
                    e.CellElement.Image = Resources.Blanco;
                }
                e.CellElement.ImageAlignment = ContentAlignment.MiddleLeft;
                e.CellElement.TextImageRelation = TextImageRelation.ImageBeforeText;
            }
            else
            {
                e.CellElement.ResetValue(LightVisualElement.ImageProperty, ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.ImageAlignmentProperty, ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.TextImageRelationProperty, ValueResetFlags.Local);
            
        }
    }
     
    private bool GridColumnGroup_RowEsEpigrafe_ColumnNombre(GridViewCellEventArgsBase e)
    {
        return myRadGridView.ViewDefinition is ColumnGroupsViewDefinition
               && e.Column.Name == COLUMNA_NAME
               && e.Row.Index > -1
               && e.Row.HierarchyLevel == 0;
    }

     

                 'Resources.Blanco' is simply a transparent image with a certain width to respect the indentation of the text, 'Resources.ExpandTrue' is rotated triangule image y 'Resources.ExpandFalse' is the triangule image pointing to the text

                 This pretend the behavior.

    I hope I have been helpful.

     

     

     

     

     

     


  9. Carlos
    Carlos avatar
    4 posts
    Member since:
    Apr 2016

    Posted 07 Apr Link to this post

    The Project, rename to .zip extension
  10. Carlos
    Carlos avatar
    4 posts
    Member since:
    Apr 2016

    Posted 07 Apr in reply to Carlos Link to this post

    One photo
  11. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 08 Apr Link to this post

    Hello Carlos,

    Thank you for writing.

    I would like to note that feature was introduced in Q3 2015 (version 2015.3.930). Feel free to upgrade in order to benefit from the improvements.

    As to the provided sample solution,I have also updated your Telerik points for the community effort.

    I hope this information helps. Should you have further questions I would be glad to help.

     Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  12. Carlos
    Carlos avatar
    4 posts
    Member since:
    Apr 2016

    Posted 08 Apr Link to this post

    ah, thanks for indicate this update. The application of my company is very big and ever have updated Telerik, but is very expensive. Well, at least I could give a possible solution for people who are in that case.
Back to Top
UI for WinForms is Visual Studio 2017 Ready