Javascript 如何在JTable中添加页脚行

Javascript 如何在JTable中添加页脚行,javascript,asp.net-mvc-4,jtable,Javascript,Asp.net Mvc 4,Jtable,如何在中添加页脚行, 我使用的是JTable2.4.0版本的js文件和MVC4 参考文献 Samir您可以从中使用jquery.jtable.footer.js jtable扩展 并为页脚配置列,如下所示 Balance: { title: 'Balance', width: '70', create:false,

如何在中添加页脚行, 我使用的是JTable2.4.0版本的js文件和MVC4

参考文献

Samir您可以从中使用jquery.jtable.footer.js jtable扩展

并为页脚配置列,如下所示

           Balance: {
                    title: 'Balance',
                    width: '70',
                    create:false,
                    edit: false,
                    display: function (data) {
                            return "£ " + data.record.Balance;
                    },
                    footer: function (data) {
                        var total = 0;
                        $.each(data.Records, function (index, record) {
                            total = Number(record.Balance);
                        });
                        return ("£"+total.toFixed(2));
                    }
                }

我正在使用footer.js文件

请参阅更多jtable扩展


我已经为我的jtable实现了这一点,并且遇到了隐藏列和页脚字段排列不正确的问题。我特别将ID列作为表中的第一列,但在jtable定义中将其可见性设置为hidden

我通过对类文件和基jtable文件进行两次小的编辑克服了这一问题,我不确定是否可以将其合并到类文件中以使其更完整,并且不会被基类更新破坏

修改的类扩展文件:

_createFooterCellForField: function (fieldName, field) {
        var style = "";
        if(field.visibility == 'hidden') style = ' style="display: none;" ';
        return $('<th class="jtable-column-footer" '+style+'>' +
            '<div class="jtable-column-footer-container"><span class="jtable-column-footer-text"></span></div></th>');
    }
成为:

.find('>thead >tr >th:nth-child(' + columnIndexInTable + '),>tbody >tr >td:nth-child(' + columnIndexInTable + '),>tfoot >tr >th:nth-child(' + columnIndexInTable + ')')
如果通过右键单击关联菜单选择列,则在基类中隐藏/显示页脚单元格和列的其余部分两次。 这些编辑是在第4500行附近的_changeColumnVisibilityInternal:function columnName,visibility{函数中完成的

同样在上面的例子中,你的总公式有点不正确,应该是total+=Numberrecord.Balance

.find('>thead >tr >th:nth-child(' + columnIndexInTable + '),>tbody >tr >td:nth-child(' + columnIndexInTable + '),>tfoot >tr >th:nth-child(' + columnIndexInTable + ')')