表格下面动态添加合计

        var jqData = (from s in queryResult
                              select new
                              {
                                  id = s.ContractGuid,//定义当前行数据的一个传输识别名称,一般以主键为名称,可以省略()
                                  cell = new object[]
                                                 {
                                                     s.ContractGuid,
                                                     Convert.ToDateTime(s.CreateDate).ToString("yyyy-MM-dd"),
                                                    workFlowBLL.GetWorkFlowRuleCategoryByGuid((Guid)s.WorkFlowCategoryGuid),        //业务类型  
                                                 
                                                     s.CompanyName,  //公司名称
                                                     s.ContractCode,//合同编号
                                                     workFlowBLL.getPayMoney(s.ContractGuid, 1),
                                                      workFlowBLL.getPayMoney(s.ContractGuid, 2,true),
                                                      um.GetUserName (  s.SaleManagerGuid)

                                                  }
                              }).ToList();
                var sumObj = new
                {
                    id = new Guid(),
                    cell = new object[]{
                        "",
                        "合计",
                        "",
                        "",
                        "",
                        queryResultSum.Sum(p=> workFlowBLL.getPayMoney(p.ContractGuid, 1)),
                           queryResultSum.Sum(p=> workFlowBLL.getPayMoney(p.ContractGuid, 2,true)),
                           ""

              }
                };
                jqData.Add(sumObj);

                //以json格式传输,依次以”total/page/records/rows"封装,名称固定
                var jsonData = new
                {
                    total = PageCount,
                    page,
                    records = RecordCount,
                    rows = jqData
                };

转载于:https://www.cnblogs.com/520cc/p/3794997.html

Ant Design Vue 表格支持在表格底部添加合计行,可以通过 `footer` 属性来设置。下面是一个简单的示例: ```html <template> <a-table :columns="columns" :data-source="dataSource" :footer="footer"> <template #name="text"> {{ text }} </template> </a-table> </template> <script> export default { data() { return { columns: [ { title: '姓名', dataIndex: 'name', key: 'name' }, { title: '年龄', dataIndex: 'age', key: 'age', align: 'right', // 定义合计函数 customRender: (text, record, index) => { if (index === this.dataSource.length - 1) { return <span>{{ this.sumAge }}</span>; } return <span>{{ text }}</span>; } } ], dataSource: [ { name: '张三', age: 20 }, { name: '李四', age: 25 }, { name: '王五', age: 30 } ] }; }, computed: { sumAge() { let sum = 0; this.dataSource.forEach(item => { sum += item.age; }); return sum; }, footer() { return () => { return ( <a-table-row> <a-table-cell>合计</a-table-cell> <a-table-cell align="right">{{ this.sumAge }}</a-table-cell> </a-table-row> ); }; } } }; </script> ``` 在上面的示例中,我们在表格的第二列定义了一个 `customRender` 函数,用于自定义渲染单元格内容。当渲染到最后一行时,我们在单元格中显示所有年龄的总和。 然后,我们通过 `computed` 计算属性定义了一个 `footer` 函数,用于渲染表格底部。在该函数中,我们返回一个 `a-table-row` 元素,其中包含两个 `a-table-cell` 元素,分别显示“合计”和总年龄。最后,我们将 `footer` 属性设置为该函数即可。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值