GridViewExpression and nested data

5 posts, 1 answers
  1. Rod
    Rod avatar
    17 posts
    Member since:
    Jul 2014

    Posted 12 Aug 2014 Link to this post

    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?

     

     

     

     

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Aug 2014 Link to this post

    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.
     
  3. Rod
    Rod avatar
    17 posts
    Member since:
    Jul 2014

    Posted 13 Aug 2014 in reply to Dimitrina Link to this post

    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
  4. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 Aug 2014 Link to this post

    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.
     
  5. Rod
    Rod avatar
    17 posts
    Member since:
    Jul 2014

    Posted 14 Aug 2014 in reply to Dimitrina Link to this post

    Thanks for investigating it further.

    Rod
Back to Top