使jqgrid仅在组的最后一行显示单个组页脚 [英] Make jqgrid only show single group footer at last row in group

查看:64
本文介绍了使jqgrid仅在组的最后一行显示单个组页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我在jqgrid中使用分组和分页.数据很长,每个组可能跨越jqgid中的几页.我应用了组总计,似乎组总计存在于每个页面上,并且基于当前页面上现有行的计算(总和).在我的用例中,这是一种误导,我希望在每个组的最后一行之后显示组总数. 我正在使用v5.1.1版本(Guriddo jqGrid JS) 可以实现吗?

Currently I'm using group and pagination in jqgrid. The data is long and each group might cross a few page in jqgid. I'm apply the group total and it seems the group total exists at every page and the calculate (sum) base on the existing row at current page. In my use case it is misleading, I wish to show group total after last row of each group. I'm using version v5.1.1 (Guriddo jqGrid JS) Is it achievable?

$grid.jqGrid({

            data: dataarray,
            datatype: 'local',
            height: 'auto',
            width: '100%',
            viewrecords: true,
            sortable: true,
            loadonce: true,
            colNames: columnarray,
            colModel: columnmodelarray,
            rownumbers: true,
            grouping: true, 

            rowNum: 20,
            gridview: true, 
            regional : 'en',
            autowidth:true, 
            shrinkToFit:false,
            rowList: [20, 50, 100, 200,400,999999999999],           
            userDataOnFooter: true,
            footerrow:true,
            sortname:sortname,
            sortorder:sortorder,
            colMenu : true,

            pager: pagerid,
            groupingView:groupviewjsondata,
            loadComplete:function()
            {
                //calculate total to put at bottom
                var columncontent={};
                var i=0;
                var lastcolumn='';

                var isshownumber=0;

                $.each(colmodels,function(colno,colobj)
                {
                    if(colobj.datatype=='number' && colobj.withtotal == true)
                    {
                        var tmptotal=0;
                        $.each(rp.result.data,function(row_id,row)
                        {
                            if(typeof row[ colobj['name']] =='string')
                            {
                                row[ colobj['name']]=parseFloat(row[ colobj['name']]);
                            }

                            tmptotal += row[ colobj['name']];
                        });
                        columncontent[colobj['name']]=tmptotal;
                        isshownumber++;

                    }
                    if( isshownumber==1) 
                    {                       
                        columncontent[lastcolumn]='<div style="text-align:right">'+lang('Total')+'</div>';                      
                    }
                    if((colobj.datatype=='date' || colobj.datatype=='string')&& (colobj.hidden===undefined ||colobj.hidden==false) )
                    {
                        lastcolumn=colobj['name'];  
                    }

                });

                $grid.jqGrid('footerData','set',columncontent);

            }
        });

推荐答案

请检查

Please check this demo - the total is not per page, but per group see the group value AROUT. The only that I can think is that you provide the data dynamically per page (from server with paging) and not at once - in this case it is as you describe

这篇关于使jqgrid仅在组的最后一行显示单个组页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆