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

Setting Text in Cell removes Expand-Icon

1 Answer 45 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Matthias
Top achievements
Rank 1
Matthias asked on 25 Feb 2014, 11:57 AM
Hi,
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.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 28 Feb 2014, 12:25 PM
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.


Regards,
Konstantin Dikov
Telerik
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.
Tags
PivotGrid
Asked by
Matthias
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or