This is a migrated thread and some comments may be shown as answers.
Grid footer total when null
1 Answer 15 Views
This is a migrated thread and some comments may be shown as answers.
MBEN
Top achievements
Rank 1
MBEN asked on 21 Mar 2018, 10:41 PM

Hi, I have grouping enabled on my grid and I show my grid as collapsed on the first load.

If my column value is null I show a 'n/a' but it shows a blank value in the group footer. Is it possible to show the n/a in the group footer as well? 

<telerik:GridTemplateColumn HeaderText="Jan" UniqueName="Jan" DataField="Jan" Aggregate="Sum" FooterAggregateFormatString="{0:c2}">
<ItemTemplate>
<%#(String.IsNullOrEmpty(Eval("Jan").ToString()) ? "n/a" : Eval("Jan", "{0:c2}"))%>
</ItemTemplate>
 </telerik:GridTemplateColumn>

 

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 26 Mar 2018, 05:09 PM
Hi,

We've tested the code snippet and is working on our end. Have you had the chance to check the DataType bound to the column in question? Perhaps, it is neither an empty string nor a null value.

Eventually, you may setup a condition that is checking for DBNull.Value instead of null.
<telerik:GridTemplateColumn HeaderText="Jan" UniqueName="Jan" DataField="Jan" Aggregate="Sum" FooterAggregateFormatString="{0:c2}">
    <ItemTemplate>
        <%#((Eval("Jan") == System.DBNull.Value) ? "n/a" : Eval("Jan", "{0:c2}"))%>
        <%--<%#(String.IsNullOrEmpty(Eval("Jan").ToString()) ? "n/a" : Eval("Jan", "{0:c2}"))%>--%>
    </ItemTemplate>
</telerik:GridTemplateColumn>

If you'd like to display data in the GroupFooter, you can use GroupFooterTemplate similar to the example below:
<telerik:RadGrid ID="RadGrid11" runat="server">
    <GroupFooterTemplate>
        <%#(String.IsNullOrEmpty(Eval("Jan").ToString()) ? "n/a" : Eval("Jan", "{0:c2}"))%>
    </GroupFooterTemplate>
</telerik:RadGrid>

I look forward to having your feedback.

Kind regards,
Attila Antal
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
MBEN
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or