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

Sum Aggregatefunction showing error while binding gridview itemsource as datatable

4 Answers 119 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
lakshmi jeeva
Top achievements
Rank 1
lakshmi jeeva asked on 07 Apr 2011, 04:05 PM
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

 

 

 

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 07 Apr 2011, 04:25 PM
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
0
lakshmi jeeva
Top achievements
Rank 1
answered on 07 Apr 2011, 06:12 PM
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
0
Vlad
Telerik team
answered on 08 Apr 2011, 08:39 AM
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
0
Sunil
Top achievements
Rank 1
answered on 11 Jul 2014, 08:29 PM
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}" />
Tags
GridView
Asked by
lakshmi jeeva
Top achievements
Rank 1
Answers by
Vlad
Telerik team
lakshmi jeeva
Top achievements
Rank 1
Sunil
Top achievements
Rank 1
Share this question
or