关闭

Ext中Store数据的操作【添加统计行】

2521人阅读 评论(0) 收藏 举报
分类:

var deletelist="";

var addauthlist="";

var addeditlist="";

var adddownloadlist="";

 

var rowCount = Ext.getCmp("authgrid").store.getCount();

for (var i = 0;i < rowCount; i++) {

var record = Ext.getCmp('authgrid').getStore().getAt(i);

//删除

if (record.data.auth == '0' && record.data.authid != ""){

deletelist +=record.data.authid + ',';

} if (record.data.edit == '0'&& record.data.editid != "") {

deletelist +=record.data.editid + ',';

} if (record.data.download == '0'&& record.data.downloadid.downloadid != ""){

deletelist +=record.data.downloadid + ',';

}

 

//添加

if (record.data.authid == "" && record.data.auth == '1') {

addauthlist +=record.data.guid + ',';

}if (record.data.editid == ""&& record.data.edit == '1') {

addeditlist +=record.data.guid + ',';

}if (record.data.downloadid == ""&& record.data.download == '1') {

adddownloadlist +=record.data.guid + ',';

}           

}

 

 

添加合计行

gridstore.load({params: { start: 0, limit: pageSize }, callback: function() { amountsum(); } });

@*-----------合计-----------*@

<script>

    function amountsum(){

        //var rowCount =Ext.getCmp("financepaymentgrid").store.getCount();

        varrowCount = gridstore.getCount();

        var p = newExt.data.Record({ fields: ['id', 'cmp_id', 'cmlongname', 'paymnet_date', 'crop_id', 'paymnet_name', 'paymnet_item', 'amount', 'verification', 'difference', 'statename', 'paymnet_state', 'paymnet_gen_time', 'paymnet_acc_time', 'paymnet_last_verifi_time', 'paymnet_final_verifi_time', 'pay_appointed_day', 'gen_id'] });//定义一行要插入的record

        var amount= 0, verification = 0, difference = 0;

        gridstore.each(function (record) {

            if(record.data.amount != null) {

                amount +=Number(record.data.amount);//叠加需要合计的列值返回给sum

            }

            if(record.data.verification != null) {

                verification +=Number(record.data.verification);//叠加需要合计的列值返回给sum

            }

            if(record.data.difference != null) {

                difference +=Number(record.data.difference);//叠加需要合计的列值返回给sum

            }

        });

        //Ext.getCmp('financepaymentgrid').store.each(function(record) {

        //    if(record.data.amount != null) {

        //       amount += Number(record.data.amount);//叠加需要合计的列值返回给sum

        //    }

        //});

       

        p.set('id', '');

        p.set('cmp_id', '');

        p.set('cmlongname', '<fontstyle=\'color:red;line-height:25px;font:bold;font-size:large;\'>合计</font>');

        p.set('paymnet_date', '');

        p.set('crop_id', '');

        p.set('paymnet_name', '');

        p.set('paymnet_item', '');

        p.set('amount', '<font style=\'color:red;line-height:25px;\'>' + amount + '</font>');//合计值放到num列中

        p.set('verification', '<fontstyle=\'color:red;line-height:25px;\'>' + verification + '</font>');

        p.set('difference','<fontstyle=\'color:red;line-height:25px;\'>' + difference + '</font>');

        p.set('statename','');

        p.set('paymnet_state', '');

        p.set('paymnet_gen_time', '');

        p.set('paymnet_acc_time', '');

        p.set('paymnet_last_verifi_time', '');

        p.set('paymnet_final_verifi_time', '');

        p.set('pay_appointed_day', '');

        p.set('gen_id', '');

        //Ext.getCmp('financepaymentgrid').store.insert(0,p);//将赋值后的新行插入到grid的第一行中

        gridstore.add(p);

    }   

</script>

 

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:123876次
    • 积分:1653
    • 等级:
    • 排名:千里之外
    • 原创:52篇
    • 转载:9篇
    • 译文:0篇
    • 评论:4条
    最新评论