美文网首页
grid添加合计功能

grid添加合计功能

作者: LCF_全博 | 来源:发表于2019-07-24 16:16 被阅读0次

    效果图

    dataSource.png

    前段代码

    grid.png

    注意点:

    • serverAggregates: true,
    • aggregate: [{field: "wareAmt", aggregate: "sum"}]

    后段代码

    controller类

    public AggregatesResponseData queryTotal(FsUseFund dto, @RequestParam(defaultValue = DEFAULT_PAGE) int page,
                                                 @RequestParam(defaultValue = DEFAULT_PAGE_SIZE) int pageSize, HttpServletRequest request) {
            IRequest requestContext = createRequestContext(request);
            AggregatesResponseData aggregatesResponseData = service.selectSumUseFundNew(requestContext, dto, page, pageSize);
            return aggregatesResponseData;
        }
    

    controller返回的是AggregatesResponseData数据

    service类

    Map<String,Map<String,Object>> aggregates=new HashMap<>();
    Map<String,Object> wareAmtSumA=new HashMap<>(); 
    wareAmtSumA.put(FsUseFund.AGGREGATE_SUM,wareAmtSum);
    aggregates.put(FsUseFund.FIELD_WARE_AMT,wareAmtSumA);
    
    
    AggregatesResponseData aggregatesResponseData = new AggregatesResponseData(fsUseFunds);
    aggregatesResponseData.setAggregates(aggregates);
    return aggregatesResponseData;
    

    fsUseFunds存的是需要返回前台的List数据
    aggregates存的是map函数,里面包含各列的数据。各列的数据是以map的形式存储。
    FsUseFund.FIELD_WARE_AMT是前台的列名字段,
    FsUseFund.AGGREGATE_SUM是sum

    相关文章

      网友评论

          本文标题:grid添加合计功能

          本文链接:https://www.haomeiwen.com/subject/fpzxrctx.html