Unplanned
Last Updated: 01 Apr 2025 15:47 by Benjamin
Stenly
Created on: 17 Mar 2025 09:53
Category: TreeListView
Type: Bug Report
4
TreeListView: DataFormatString property of the columns is not applied on child rows

Currently, the DataFormatString property of the columns is applied only to the top-level rows and not to the child ones.

To work this around, create a new DataTemplate for the CellTemplate property of the column and set the StringFormat property of the Binding instance for the element that will be used to display the cell's value in view mode.

<telerik:GridViewDataColumn.CellTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding MyPropertyValue, StringFormat=N2}"/>
    </DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>

 

1 comment
Benjamin
Posted on: 01 Apr 2025 15:47
Here is another workaround posted by Martin on a duplicated item :



        private void RadTreeListView_DataLoaded(object sender, EventArgs e)
        {
            ((QueryableCollectionView)((RadTreeListView)sender).Items.SourceCollection).ItemType = typeof(YOUR BASE TYPE);
        }


Workaround: register to DataLoaded event in your RadTreeListView and inside the codebehind method do something like this:

((QueryableCollectionView)((RadTreeListView).Items.SourceCollection)).ItemType = typeof(yourbasetype - probably generic type of you bound collection)

(yes its ugly, you can make it nicer and generic and into a behaviour, but im not paid for writing this)

Formating does not work because if the "top" collection contains only one type, then column thinks (well its more complicated, but it douesnt matter) its only for this type and fails to return formated string for second level which has different type - it returns value but does not aply the stringformat.

By settings the type, the column will be happy that the dataitem is of type derived from collectionview item type and will return value with sting applied.

At least this works for me and my problem.

 

PS: Taging this as feature request is just plain wrong, beacuse its obvious bug.