Sum Aggregatefunction showing error while binding gridview itemsource as datatable

5 posts, 0 answers
  1. lakshmi jeeva
    lakshmi jeeva avatar
    20 posts
    Member since:
    Jul 2012

    Posted 07 Apr 2011 Link to this post

    Hi,

          I have created telerik gridview and i have binded datatable as itemssource of radgridview. Find below definiton.

         

    <

     

     

    tkGrid:RadGridView x:Name="grdRows"

     

    SelectionMode="Extended" ShowGroupPanel="False"

     

     

    AutoGenerateColumns="False"

    RowIndicatorVisibility="Collapsed"

     

     

    ScrollMode="RealTime" ShowColumnFooters="True" ShowGroupFooters="True"

     

    ScrollViewer.VerticalScrollBarVisibility="Auto"

     

    ScrollViewer.HorizontalScrollBarVisibility="Auto"

     

     

    EnableRowVirtualization="False"

     

    EnableColumnVirtualization="False"

     

    HorizontalAlignment="Stretch"

     

     

    VerticalAlignment="Stretch"

     

     

    HorizontalGridLinesBrush="White"

     

     

    VerticalGridLinesBrush="White"

     

     

    MaxHeight="700"

     

     

    Visibility="Visible" >

     

     

    <tkGrid:RadGridView.Columns>

     

     

    <tkGrid:GridViewDataColumn

     

     

    Width="Auto"

    UniqueName="Rep"

     

     

     

    DisplayIndex="0"

     

     

    Header="Rep"

     

    DataMemberBinding="{Binding Name}"

     

    IsSortable="True"

     

    TextWrapping="Wrap">

     

     

    <tkGrid:GridViewDataColumn.CellTemplate>

     

     

    <DataTemplate>

     

     

    <HyperlinkButton x:Name="hlnkEmployee" Foreground="Blue" Content="{Binding Name}" ToolTipService.ToolTip="{Binding Name}" ClickMode="Press" TargetName="_blank" >

    </HyperlinkButton >

     

    </DataTemplate>

     

     

    </tkGrid:GridViewDataColumn.CellTemplate>

     

     

    </tkGrid:GridViewDataColumn>

     

     

     

      

    <tkGrid:GridViewDataColumn

     

    UniqueName="Hours"

     

    Header="Hours"

     

    FooterTextAlignment="Right"

     

     

    TextAlignment="Right"

     

    TextWrapping="Wrap"

    DataMemberBinding="{Binding Hours}"

     

     

    IsResizable="True">

      

    <

     

     

    tkGrid:GridViewColumn.AggregateFunctions>

     

      <tkData:SumFunction SourceField="Hours" ResultFormatString="{}{0}" />

     

      </tkGrid:GridViewColumn.AggregateFunctions >

     

     

    </tkGrid:GridViewDataColumn>

     

    </tkGrid:RadGridView.Columns>

     

     

    </tkGrid:RadGridView>

    I am binding above radgridview itemssource as datatable. If i run the page it is showing error'No generic method sum on type 'System.linq.enumerable' like that. herewith i have attached the screenshot.

    If we bind property of class,aggregate function is working fine. But if we use datatable then it is showing an error.

    In some of forums in telerik mentioned that we have to give datatype of gridviewdatacolumn. So i have tried created taht column in code behind and gave datatype.Still i am getting same error.

    Please anyone give the example for sum aggregatefunction of gridviewdatacolumn if we bind gridview itemssource as datatable.

    Regards
    Lakshmi

     

     

     

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 07 Apr 2011 Link to this post

    Hi,

     Can you verify if Hours is numeric? 

    Greetings,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. lakshmi jeeva
    lakshmi jeeva avatar
    20 posts
    Member since:
    Jul 2012

    Posted 07 Apr 2011 Link to this post

    Hi,

        Hours is a decimal column. It will display as 1.45 like that. But i have applied aggregate function to numeric columns also.I got same error while binding grid to datatable.

    Regards
    Lakshmi
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 08 Apr 2011 Link to this post

    Hi,

     I've just tried this with our latest official version (Q1 2011) however everything worked as expected on my end. You can check the attached project for reference. 

    Best wishes,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Sunil
    Sunil avatar
    2 posts
    Member since:
    Oct 2012

    Posted 11 Jul 2014 Link to this post

    I had the same issue. Since the type of the SourceField cannot be inferred it needs to be specified in the sumFunction explicitly. So the above code can be fixed by including the SourceFieldType as shown below.

    <tkData:SumFunction SourceField="Hours" SourceFieldType="system:Decimal" ResultFormatString="{}{0}" />
Back to Top
DevCraft banner