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

Problem with RadGrid GridCalculatedColumn Expression

4 Answers 224 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 27 Dec 2012, 04:02 PM
I have a grid with a column defined as follows:
<telerik:GridCalculatedColumn FilterControlAltText="Filter column1 column" UniqueName="YrPercent" 
     DataFields="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,minTotal" 
     Expression="(({0} + {1} + {2} + {3} + {4} + {5} + {6} + {7} + {8} + {9} + {10} + {11})  / {12}) * 100.0" 
     Aggregate="Sum" HeaderText="Yr %" DataFormatString="{0:N3}%" FooterAggregateFormatString="{0:N3}%" 
     DataType="System.Double" FilterControlWidth="30px">
     <FooterStyle HorizontalAlign="Right" />
     <HeaderStyle Width="3.5%" HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Right" />
  </telerik:GridCalculatedColumn>


As you can see, I'm looking for a percentage (in this case rather small ones, about .147 for example).  All of the fields referenced in the calculation are integers.  I've bound the grid with a call to a IQueryable method returning a call from LinqToSQL.  

As is, this grid crashes with a Operator '*' incompatible with operand types 'Int32?' and 'Double' error.  After much searching of your forums, I set the grid's  EnableLinqExpressions property = false and everything seems to work.

2 questions.
  1. Is there any way to get that expression to work without setting EnableLinqExpressions=false?
  2. What do I lose if I do set EnableLinqExpressions=false?



4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 28 Dec 2012, 04:29 PM
0
Boris
Top achievements
Rank 1
answered on 28 Dec 2012, 04:38 PM
???

That has nothing to do with my question.   I was asking about calculation expressions.
0
Shinu
Top achievements
Rank 2
answered on 02 Jan 2013, 10:24 AM
Hi,

Please check this forum thread which discuss the same.

Thanks,
Shinu.
0
Boris
Top achievements
Rank 1
answered on 02 Jan 2013, 01:41 PM
I'm still not sure I get it. 

Are you saying that if I were to leave EnableLinqExpressions = true, I would I need to rephrase that simple sum equation as some sort of a Linq statement?  If so I'm not quite sure how.  I don't see anything specific in that thread or it's links.  (I don't think I've encountered Dynamic Linq before either.)
Tags
Grid
Asked by
Boris
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Boris
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or