Thanks
10 Answers, 1 is accepted
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
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
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
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
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.
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