EasyUI的DataGrid合击汇总页脚使用教程

本文介绍如何使用EasyUI的Datagrid组件实现页脚汇总功能,通过修改JSON数据格式,加入footer数组来显示订单数量和金额的总和。提供了一个C#服务器端代码示例,展示了如何动态生成包含汇总信息的Datagrid数据。

最近做订单处理,需要汇总订单明细的数量和金额,所以涉及到使用EasyUI的Datagrid组件的页脚汇总功能,先看了一下官方教程,如下:

Tutorial » Displaying Summary Information in DataGrid's Footer

In this tutorial, we will show you how to display the summary rows in the footer of datagrid.

To display footer row, you should set the showFooter property to true and then prepare the footer rows that is defined in datagrid data. Below is the sample data:

  1. {"total":1,"rows":[{"id":1,"name":"Chai","price":18.00}],"footer":[{"name":"Total","price":18.00}]}
Create DataGrid
  1. <tableid="tt"title="DataGrid"class="easyui-datagrid"style="width:400px;height:250px"
  2. url="data/datagrid17_data.json"
  3. fitColumns="true"rownumbers="true"showFooter="true">
  4. <thead>
  5. <tr>
  6. <thfield="name"width="80">Product Name</th>
  7. <thfield="price"width="40"align="right">Unit Price</th>
  8. </tr>
  9. </thead>
  10. </table>

The footer rows are same as body rows, so you can display more than one summary information on footer.

Download the EasyUI example:
上面的教程不用多说,大家可以看一下,重点是再Json数据的格式问题上,需要加入footer的数组记住是数组,并且数组的列要和你datagrid中的列名一致,需要汇总的列有值,其他列可以不赋值
我的服务器端代码如下:
[csharp]
public Dictionary getOrderList(string ordercode)
{
Dictionary result=new Dictionary();
if (String.IsNullOrEmpty(ordercode))
{
result.Add("total",1);
result.Add("rows", new BuyOrderList());
result.Add("footer", new { Goods_Name = "合计", Buy_Number = 0, Order_Amount=0 });
return result;
}
else
{
List datas = new BusinessLogic().Select(new BuyOrderList() { Order_Code = ordercode });
result.Add("total", datas.Count);
result.Add("rows", datas);
List footer=new List();
footer.Add(new BuyOrderList(){Identifier=-2,Goods_Name="合计:",Buy_Number=datas.Sum(m =&gt; m.Buy_Number),Order_Amount=datas.Sum(m =&gt; m.Order_Amount)});
result.Add("footer",footer);
return result;
}
}
[/csharp]

转载于:https://www.cnblogs.com/mikel/archive/2011/11/29/2267673.html

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值