用ext 实现类似在 excel中能求和,求平均数,求总的功能。

解决方案 »

  1.   


    Ext.ux.grid.GridSummary百度extjs这个插件
    里面有sum、avg、max、min
      

  2.   

    类似这样的?文本区域中输入1+2=,然后回车得结果
    <body>
    <textarea rows="3" cols="20" id="calculator" style="background-color:#66FF99;"></textarea>
    <script>
    var cal = document.getElementById('calculator');
    cal.onkeydown = function(e){
        e = e || event;
        if(this.style.backgroundColor == '#f00')this.style.backgroundColor = '#66FF99';
        if(e.keyCode == 13){
            if(/^[\d,\.,\+,\-,\*,\/,\(,\)]*\=$/.test(this.value)){
                this.value = eval(this.value.replace('=',''));
            }else{
                this.style.backgroundColor = '#f00';
            }
            return false;
        }
    }
    </script> </body>
      

  3.   

    差不多,但是是选中要grid那里面的单元里面的值
      

  4.   

    求选定行的和 
    var records = sm.getSelections();
    var sum = 0;
    for (var i = 0; i < sm.getCount(); i++) {
       sum=sum+records[i].get('列名');
    }
    其他同理
      

  5.   


    sm就是你的GridPanel属性,你可以在外面定义sm
    var sm= new Ext.grid.CheckboxSelectionModel({ singleSelect: false});  var EHGBillGrid = new Ext.grid.GridPanel({
                    loadMask: {
                        msg: "请稍等,正在查询数据..."
                    },
                    store: Store,
                    margins: '1 1 1 1',
                    region: 'center',
                    cm: X7_Business_EHGBillcm,
                    sm: sm,
                    stripeRows: true,
                    bbar: new Ext.PagingToolbar({
                        store: EHGBillStore,
                        displayInfo: true,
                        pageSize: conpageSize,
                        emptyMsg: '没有数据可显示'
                    })
                });
      

  6.   

    哦  我要把它写成像excel里面  用一个按钮对其进行计算,是要写在监听里面,还是写在按钮事件上??能分析一下思路不??
      

  7.   

    可以定义cellclick事件,当触发这个事件以后可以将它的值填到你的自定义属性里,在定义一个按钮就好了.