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

calculated column not handling negative values

2 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Donna
Top achievements
Rank 1
Donna asked on 08 Aug 2017, 06:27 PM

I have a GridCalculatedColumn that is not summing up the values properly when there is a negative value.  Currently it is giving a total that is treating the negative value as if it's positive.  The negative values (p1,p2,p3..etc) are shown in brackets indicating it's negative on the grid but is not calculated as such on the total.  Is there any setting on the gridcalculatedcolumn so that I can make sure it will consider negative values?

 

  <Columns>
                        <telerik:GridBoundColumn DataField="RESOURCE" HeaderText="Resource Name / PO" FilterControlAltText="Filter RESOURCE column"  SortExpression="RESOURCE" ReadOnly="True" UniqueName="RESOURCE" HeaderStyle-Width="100px">
                            <ColumnValidationSettings>
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="RESOURCE_ID" HeaderText="Cost Center / Vendor" FilterControlAltText="Filter RESOURCE_ID column" HeaderStyle-Width="200px" SortExpression="RESOURCE_ID" ReadOnly="True" UniqueName="RESOURCE_ID">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="LABOUR_TYPE" HeaderText="Type" FilterControlAltText="Filter LABOUR_TYPE column"  SortExpression="LABOUR_TYPE" UniqueName="LABOUR_TYPE" ReadOnly="True"  HeaderStyle-Width="80px">
                        </telerik:GridBoundColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P1" DataType="System.Double" FilterControlAltText="Filter P1 column" HeaderStyle-Width="65px" HeaderText="P1" ReadOnly="True" SortExpression="P1" UniqueName="P1" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P2" DataType="System.Double" FilterControlAltText="Filter P2 column" HeaderStyle-Width="65px" HeaderText="P2" SortExpression="P2" UniqueName="P2" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P3" DataType="System.Double" FilterControlAltText="Filter P3 column" HeaderStyle-Width="65px" HeaderText="P3" SortExpression="P3" UniqueName="P3" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P4" DataType="System.Decimal" FilterControlAltText="Filter P4 column" HeaderStyle-Width="65px" HeaderText="P4" SortExpression="P4" UniqueName="P4" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P5" DataType="System.Decimal" FilterControlAltText="Filter P5 column" HeaderStyle-Width="65px" HeaderText="P5" SortExpression="P5" UniqueName="P5" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P6" DataType="System.Decimal" FilterControlAltText="Filter P6 column" HeaderStyle-Width="65px" HeaderText="P6" SortExpression="P6" UniqueName="P6" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P7" DataType="System.Decimal" FilterControlAltText="Filter P7 column" HeaderStyle-Width="65px" HeaderText="P7" SortExpression="P7" UniqueName="P7" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P8" DataType="System.Decimal" FilterControlAltText="Filter P8 column" HeaderStyle-Width="65px" HeaderText="P8" SortExpression="P8" UniqueName="P8" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P9" DataType="System.Decimal" FilterControlAltText="Filter P9 column" HeaderStyle-Width="65px" HeaderText="P9" SortExpression="P9" UniqueName="P9" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P10" DataType="System.Decimal" FilterControlAltText="Filter P10 column" HeaderStyle-Width="65px" HeaderText="P10" SortExpression="P10" UniqueName="P10" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P11" DataType="System.Decimal" FilterControlAltText="Filter P11 column" HeaderStyle-Width="65px" HeaderText="P11" SortExpression="P11" UniqueName="P11" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" FooterText=" " DataField="P12" DataType="System.Decimal" FilterControlAltText="Filter P12 column" HeaderStyle-Width="65px" HeaderText="P12" SortExpression="P12" UniqueName="P12" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                        </telerik:GridNumericColumn>
                        <telerik:GridCalculatedColumn HeaderText="Total" HeaderStyle-Width="120px" UniqueName="TotalPrice" DataType="System.Decimal"
                            DataFields="P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12" Expression="{0}+{1}+{2}+{3}+{4}+{5}+{6}+{7}+{8}+{9}+{10}+{11}" FooterText=" "
                            Aggregate="Sum" DataFormatString="{0:$###,##0.00}">
                        </telerik:GridCalculatedColumn>
                    </Columns>

2 Answers, 1 is accepted

Sort by
0
Donna
Top achievements
Rank 1
answered on 11 Aug 2017, 12:39 PM

If I don't use the gridcalculatedcolumn, is there anyway to manually calculate the sum? What would be the syntax?

0
Donna
Top achievements
Rank 1
answered on 11 Aug 2017, 02:33 PM

I found that there is a piece of javascript sitting elsewhere in the code overwriting the results in that total column so this is no longer an issue.  Thanks.

Tags
Grid
Asked by
Donna
Top achievements
Rank 1
Answers by
Donna
Top achievements
Rank 1
Share this question
or