EasyUI的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:
- {"total":1,"rows":[{"id":1,"name":"Chai","price":18.00}],"footer":[{"name":"Total","price":18.00}]}
Create DataGrid
- <tableid="tt"title="DataGrid"class="easyui-datagrid"style="width:400px;height:250px"
- url="data/datagrid17_data.json"
- fitColumns="true"rownumbers="true"showFooter="true">
- <thead>
- <tr>
- <thfield="name"width="80">Product Name</th>
- <thfield="price"width="40"align="right">Unit Price</th>
- </tr>
- </thead>
- </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 => m.Buy_Number),Order_Amount=datas.Sum(m => m.Order_Amount)});
result.Add("footer",footer);
return result;
}
}
[/csharp]
作者:mikel
出处:http://www.cnblogs.com/mikel/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
该文章也同时发布在我的独立博客中-www.mikel.cn。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架