开发者

Telerik MVC Grid - Sum error

开发者 https://www.devze.com 2023-03-26 05:39 出处:网络
I am using the following line to get a column sum: columns.Bound(item => item.McGross).Width(50).Title(\"Amount\"开发者_开发知识库).Aggregate(aggreages => aggreages.Sum()).Format(\"{0:c}\").Foo

I am using the following line to get a column sum:

columns.Bound(item => item.McGross).Width(50).Title("Amount"开发者_开发知识库).Aggregate(aggreages => aggreages.Sum()).Format("{0:c}").FooterTemplate(result =>
            { %><%= result.Sum.Format("{0:c}") %><% });

I get error when any of the column valuse are null. How can I use "if" null put "0" for that record. Thanks in advance.


The good people at Telerik has provided an answer, here it is:

.FooterTemplate(result =>
{
  %>Total Sum: <%=
    (result.Sum == null || (double)result.Sum.Value == 0.0)
      ? "Value not available"
      : result.Sum.Format("{0:c}")
    %><%
});

It worked. Hope this could help someone else.

0

精彩评论

暂无评论...
验证码 换一张
取 消