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

Hide duplicate values /repetitions in (hierachy) grid

5 Answers 477 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dirk LX
Top achievements
Rank 1
Dirk LX asked on 29 Jan 2010, 04:55 PM
Hey folks,

I figure if there is any way to hide repeated cell values in my grid. I attached a screenshot and want to hide the redundant information in the first 3 columns. I am wondering if there might be an intelligent way of doing with the grid control.

Has anybody of you guys a cool idea to me?

I attached a screenshot which shows my actual grid and a grid which looks like it should be.
At this moment I do not have any idea except of iterating thorugh the rows. Additonally the difficulty is that this is a hierachy grid which is bound to the childtemplate by the first thre rows. So the best way should be formatting the cells with the fore color white, right?

Any thought?! ;)

Thanks in advance.

Best

5 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 01 Feb 2010, 01:14 PM
Hi Dirk LX,

If you want not to show the repeated values on the main level in hierarchy, you should subscribe to CellFormatting event. You may use the following code snippet as a sample:

private GridViewRowInfo lastRow = null;
 
 
private void radGridView_CellFormatting(object sender, CellFormattingEventArgs e)
{
    GridViewDataColumn dataColumn = e.CellElement.ColumnInfo as GridViewDataColumn;
    GridViewRowInfo row = e.CellElement.RowInfo;
 
    if (e.CellElement.IsRowHovered || row.ViewTemplate != this.radGridView.MasterGridViewTemplate)
    {
        return;
    }
 
 
    if (dataColumn != null)
    {
         
        if (lastRow == null)
        {
            lastRow = row;
            return;
        }
 
        if (lastRow != null && lastRow != row)
        {
            if (Object.Equals(row.Cells[dataColumn.UniqueName].Value, lastRow.Cells[dataColumn.UniqueName].Value))
            {
                e.CellElement.Text = String.Empty;
            }
        }
 
 
        if (dataColumn.OwnerTemplate.Columns.Count - 1 == dataColumn.Index)
        {
            lastRow = row;
        }
    }
}

Let me know if you need further assistance.

Best wishes,
Svett
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dirk LX
Top achievements
Rank 1
answered on 02 Feb 2010, 09:20 AM
Hey Svett,

thank you very much. That is pretty much that what I was looking for!

I am now wondering if there is any possibility to move the cross(plus) and minus sign to expand and collapse the childgrid to another column. In excel for example it would appear in the 2nd column if I rebuild my app there.

Thanks for your help again.

Best,
0
Svett
Telerik team
answered on 03 Feb 2010, 08:34 AM
Hi Dirk LX,

There is no way to move the cross (plus) image of the expand/collapse groups to another column. This image is placed in a special cell that resides in a special column that contains only that kind of cells.

If you have another questions, feel free to write us back.

Sincerely yours,
Svett
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Dirk LX
Top achievements
Rank 1
answered on 03 Feb 2010, 08:47 AM
Would it then be possible to hide the cross/plus cell or to now show it?

It should then be possible to insert an imagecell in the (f.e) 3rd column and initate the expansion by clicking on it, or?
0
Svett
Telerik team
answered on 04 Feb 2010, 09:46 AM
Hello Dirk LX,

Yes, you can achieve it by subscribing to CreateCell event and also adding a dummy column. Then you can create the indent cell with the plus image. You can use the following code snippet as sample:

public TicketID277646GridForm1()
{
    InitializeComponent();
 
    (this.radGridView.GridElement as GridTableElement).GroupIndent = 0;
 
    this.radGridView.CreateCell += new GridViewCreateCellEventHandler(radGridView_CreateCell);
}
 
private void radGridView_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
    GridViewDataColumn dataColumn = e.Column as GridViewDataColumn;
 
    if (dataColumn != null && dataColumn.UniqueName == "Expander" && e.CellType == typeof(GridDataCellElement))
    {
        if (e.Row is GridNewRowElement)
        {
            return;
        }
 
        e.CellElement = new GridGroupExpanderCellElement(e.Column, e.Row);
    }
}

Also you have to create a column where the expandable cells will be created for:

GridViewTextBoxColumn txtColumn = new GridViewTextBoxColumn("Expander", "Expander");
txtColumn.ReadOnly = true;
this.radGridView.MasterGridViewTemplate.Columns.Add(txtColumn);

If you feel that need further assistance, do not hesitate to write us back.

All the best,
Svett
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
GridView
Asked by
Dirk LX
Top achievements
Rank 1
Answers by
Svett
Telerik team
Dirk LX
Top achievements
Rank 1
Share this question
or