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

GridViewExpression and nested data

4 Answers 72 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rod
Top achievements
Rank 1
Rod asked on 12 Aug 2014, 08:47 PM

I have some hierarchical data where my Primary ItemSource is a List<foo>   where foo contains a property List<MonthType> Months

In my gridView  I can do the following and it displays the sub List<Months> amount information in columns

<telerik:GridViewDataColumn Header="Account Title" DataMemberBinding="{Binding AccountTitle}" />
<telerik:GridViewDataColumn Header="Jan" DataMemberBinding="{Binding Months[0].Amount}" />

...

But this does not work

<telerik:GridViewExpressionColumn Header="Total2"  UniqueName="TotalValue2" DataFormatString="{}{0:C}" Expression="Months[0].Amount + ... + Months[11].Amount" />

If I put in a simple test - this works (Where RowID is a valid in in my data Object).

<telerik:GridViewExpressionColumn Header="Total" UniqueName="TotalValue" DataFormatString="{}{0:C}" Expression="RowID * 2" />


Any ideas on how to get this simple expressionColumn to work?

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 13 Aug 2014, 08:43 AM
Hi,

I am afraid ExpressionColumn is not going to calculate the values of such nested property. This is not supported.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Rod
Top achievements
Rank 1
answered on 13 Aug 2014, 11:59 AM
That's odd, considering you are handling data binding at the nested level. 

Is there any other way (short of creating an additional property that adds everything together) to accomplish this?

Rod
0
Accepted
Dimitrina
Telerik team
answered on 14 Aug 2014, 02:22 PM
Hello,

The Expression engine is working differently than the DataMemberBinding.. 
Basically you can access simple nested properties, but not an item from a collection with indexer.
This is supported:
<telerik:GridViewExpressionColumn Expression="CustomO.Number"  Header="Stadium" />

Nevertheless, I found a workaround to be able to access the item you are interested in. You can do so with the ElementAt(index) function.
For example:
<telerik:GridViewExpressionColumn Expression="Players.ElementAt(0).Number" Header="Stadium" />

This seems to be a bug at our end and we will investigate it further.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Rod
Top achievements
Rank 1
answered on 14 Aug 2014, 02:38 PM
Thanks for investigating it further.

Rod
Tags
GridView
Asked by
Rod
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Rod
Top achievements
Rank 1
Share this question
or