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

GridCalculatedColumn - Nothing But Zeros

3 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard Weeks
Top achievements
Rank 2
Richard Weeks asked on 26 Aug 2011, 03:50 AM
Hi

If I have the following SQL:

SELECT CAST
(
    (
        CAST(10549 AS FLOAT) / CAST(93020 AS FLOAT) * 100
    )
    AS DECIMAL (10,2)
)
AS BobsPerAlice

I can expect the following output:

BobsPerAlice
11.34

I'd like to replicate this in a GridCalculatedColumn and this is what I came up with:

<telerik:GridCalculatedColumn
    DataType="System.Double"
    HeaderText="Bobs"
    UniqueName="Bobs"
    DataFields="Bobs, Alice"
    Expression="{0} / {1} * 100"
    FooterText="Bobs / Alice: "
    Aggregate="Sum">
</telerik:GridCalculatedColumn>

Unfortunately, the rows I get contain zeros for their values as does the footer item, like:

Bobs
0
0
0
...
Bobs / Alice: 0

"Bob" and "Alice" are of database type INT. Working with INTs will not work though.

What am I doing wrong?

Richard

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 31 Aug 2011, 09:18 AM
Hello Richard,

I tried to reproduce the described issue but to no avail. I am sending you a simple example based on your code, please check it out and let me know what differs in your case.

Looking forward for your reply.

Regards,
Radoslav
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Richard Weeks
Top achievements
Rank 2
answered on 01 Sep 2011, 03:17 AM
I think it's to do with the Expression. If the expression evaluates to something the GridCalculatedColumn doesn't like, it doesn't show anything.

As a more concrete example, I'm trying to take 2 columns that have a datatype of int (Litres of Fuel placed in fuel tank and Odometer reading at the time of fill-up) and show the Litres / 100Km as a footer item while still showing the individual Litres of Fuel in that column.

<telerik:GridNumericColumn 
    DataField="Odometer" 
    DataType="System.Int32" 
    HeaderText="Odometer" 
    UniqueName="Odometer">
</telerik:GridNumericColumn>
  
<telerik:GridCalculatedColumn 
    DataType="System.Int32"
    HeaderText="Litres" 
    UniqueName="Litres" 
    DataFields="Litres,Odometer" 
    Expression="({0} X 100) / {1}" 
    FooterText="L / 100 Km: "
    Aggregate="Sum">
</telerik:GridCalculatedColumn>

Does not work.

Richard
0
Radoslav
Telerik team
answered on 03 Sep 2011, 09:05 AM
Hi Richard,

Could you please try changing the Expression of the GridCalculatedColumn as following and let me know if the issue still persists:
<telerik:GridCalculatedColumn DataType="System.Int32" HeaderText="Litres" UniqueName="Litres"
                    DataFields="Litres,Odometer" Expression="({0} * 100) / {1}" FooterText="L / 100 Km: "
                    Aggregate="Sum">
                </telerik:GridCalculatedColumn>

Additionally I am sending you the modified version of the example.

Looking forward for your reply.

Regards,
Radoslav
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Richard Weeks
Top achievements
Rank 2
Answers by
Radoslav
Telerik team
Richard Weeks
Top achievements
Rank 2
Share this question
or