Setting Text in Cell removes Expand-Icon

2 posts, 0 answers
  1. Matthias
    Matthias avatar
    2 posts
    Member since:
    Feb 2012

    Posted 25 Feb 2014 Link to this post

    i need a custom filtering in my PivotGrid that is not alphabetically. Therefore i added a leading number to the data by which the grid is sorted and remove these numbers in the OnCellDataBound method like this
    e.Cell.Text = ((string) e.Cell.DataItem).Remove(0, 2);
    That causes the expand icon to disappear.

    BR, Matthias.
  2. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 28 Feb 2014 Link to this post

    Hello Matthias,

    The behavior that you are observing is due to the fact that you are adding the new value to the Cell.Text property, which will lead to the removal of all controls in the Cell.Controls collection. 

    For achieving the desired result you could traverse through the Controls collection of the Cell and change the Label control text instead. Bellow is an example of that approach:
    foreach (Control control in e.Cell.Controls)
        if (control is Literal)
            (control as Literal).Text = (e.Cell.DataItem).ToString().Remove(0, 2);

    Please give this a try and see if the result meets your requirements.

    Konstantin Dikov
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top