Extjs 如何使用summary函数计算网格中的总计

Extjs 如何使用summary函数计算网格中的总计,extjs,Extjs,我有一个有两个汇总位置的网格。我在表格的末尾有一个摘要。这很有效。但是我想要的是计算每行的总价格。我有4个专栏,分别是“安塔尔、斯图克普里斯、科廷和托塔尔”。我需要的是,在“Totaal”列中,这个总数:(Aantal X Stukprijs)-%korting(表示折扣) 这是该网格的代码: xtype: 'gridpanel', id: 'materiaalGrid',

我有一个有两个汇总位置的网格。我在表格的末尾有一个摘要。这很有效。但是我想要的是计算每行的总价格。我有4个专栏,分别是“安塔尔、斯图克普里斯、科廷和托塔尔”。我需要的是,在“Totaal”列中,这个总数:(Aantal X Stukprijs)-%korting(表示折扣)

这是该网格的代码:

  xtype: 'gridpanel',
                                id: 'materiaalGrid',
                                autoScroll: true,
                                forceFit: true,
                                store: 'MyArrayStore8',
                                columns: [
                                    {
                                        xtype: 'rownumberer'
                                    },
                                    {
                                        xtype: 'gridcolumn',
                                        dataIndex: 'naam',
                                        text: 'Naam',
                                        editor: {
                                            xtype: 'combobox'
                                        }
                                    },
                                    {
                                        xtype: 'gridcolumn',
                                        dataIndex: 'type',
                                        text: 'Type'
                                    },
                                    {
                                        xtype: 'numbercolumn',
                                        summaryType: 'sum',
                                        dataIndex: 'gewicht',
                                        text: 'Gewicht'
                                    },
                                    {
                                        xtype: 'numbercolumn',
                                        summaryType: 'sum',
                                        dataIndex: 'aantal',
                                        text: 'Aantal',
                                        editor: {
                                            xtype: 'numberfield'
                                        }
                                    },
                                    {
                                        xtype: 'numbercolumn',
                                        dataIndex: 'stuks',
                                        text: 'Stukprijs'
                                    },
                                    {
                                        xtype: 'numbercolumn',
                                        dataIndex: 'korting',
                                        text: 'Korting',
                                        editor: {
                                            xtype: 'numberfield',
                                            maxValue: 100
                                        }
                                    },
                                    {
                                        xtype: 'numbercolumn',
                                        summaryType: 'sum',
                                        dataIndex: 'stuks',
                                        text: 'Totaal'
                                    },
                                    {
                                        xtype: 'booleancolumn',
                                        dataIndex: 'verkoop',
                                        text: 'Verkoop'
                                    },
                                    {
                                        xtype: 'actioncolumn',
                                        maxWidth: 50,
                                        minWidth: 50,
                                        width: 50,
                                        defaultWidth: 50,
                                        emptyCellText: 'Delete',
                                        menuDisabled: true,
                                        items: [
                                            {
                                                handler: function(view, rowIndex, colIndex, item, e, record, row) {
                                                    var selection = me.getView().getSelectionModel().getSelection()[0];
                                                    if (selection) {
                                                        store.remove(selection);
                                                    }
                                                },
                                                altText: 'Delete'
                                            }
                                        ]
                                    }
                                ],
                                viewConfig: {
                                    enableTextSelection: false
                                },
                                features: [
                                    {
                                        ftype: 'summary'
                                    }
                                ],
                                plugins: [
                                    Ext.create('Ext.grid.plugin.RowEditing', {

                                    })
                                ],

我只能得到最下面一行的安塔尔和盖维希特之和。

要解决这个特定场景,您可以尝试这样做:

  • 对于“Aantal X Stukprijs”又名数量X单价的结果(感谢上帝Google translator的存在!),您可以创建一个计算字段,在字段声明中实现convert功能,如下所示:

您可以看到a,希望它有帮助。

转换部分工作完美!对于网格,部分。我不能让它工作。我也尝试了architect,但似乎我把它放错了位置。您可以尝试在网格声明中添加侦听器,就像前面的示例中一样 { name: 'total', type: 'number', convert: function(value, record) { if(!value) { // Only calculate the value if no value set since the // Calculated total column will fill this field with a real // value we don't want to mess value = record.get('price') * record.get('units'); } return value; } }
    grid.on('edit', function(editor, e) {
           // commit the changes right after editing finished    
           e.record.set('total'); // force total re-calculation
           e.record.commit(); 
   });