Hide duplicate values /repetitions in (hierachy) grid

6 posts, 0 answers
  1. Dirk LX
    Dirk LX avatar
    6 posts
    Member since:
    Nov 2009

    Posted 29 Jan 2010 Link to this post

    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

  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 01 Feb 2010 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dirk LX
    Dirk LX avatar
    6 posts
    Member since:
    Nov 2009

    Posted 02 Feb 2010 Link to this post

    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,
  5. Svett
    Admin
    Svett avatar
    728 posts

    Posted 03 Feb 2010 Link to this post

    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.
  6. Dirk LX
    Dirk LX avatar
    6 posts
    Member since:
    Nov 2009

    Posted 03 Feb 2010 Link to this post

    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?
  7. Svett
    Admin
    Svett avatar
    728 posts

    Posted 04 Feb 2010 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready