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

View definition and hierarchical grid

10 Answers 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Antonio Ibáñez Oliva
Top achievements
Rank 1
Antonio Ibáñez Oliva asked on 04 Jul 2012, 11:14 AM
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

10 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 09 Jul 2012, 10:23 AM
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 >>
0
Antonio Ibáñez Oliva
Top achievements
Rank 1
answered on 17 Jul 2012, 08:22 AM
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

0
Ivan Petrov
Telerik team
answered on 20 Jul 2012, 07:50 AM
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 >>
0
Jay
Top achievements
Rank 1
answered on 22 Aug 2014, 05:47 PM
Any news on this? The bug still remains with the latest release.
0
Stefan
Telerik team
answered on 26 Aug 2014, 10:04 AM
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.
 
0
Carlos
Top achievements
Rank 1
answered on 07 Apr 2016, 09:16 AM

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.

 

 

 

 

 

 


0
Carlos
Top achievements
Rank 1
answered on 07 Apr 2016, 04:42 PM
The Project, rename to .zip extension
0
Carlos
Top achievements
Rank 1
answered on 07 Apr 2016, 04:51 PM
One photo
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Apr 2016, 07:50 AM
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.
0
Carlos
Top achievements
Rank 1
answered on 08 Apr 2016, 10:06 AM
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.
Tags
GridView
Asked by
Antonio Ibáñez Oliva
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Antonio Ibáñez Oliva
Top achievements
Rank 1
Jay
Top achievements
Rank 1
Stefan
Telerik team
Carlos
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or