如何使用 jQuery 在表中创建子组?
我正在创建一个股票投资组合。每行都是一只股票及其数据,包括损益。每行都有一个用户可以指定的 groupid。我的想法是:
- 在步骤 #1 之后根据 groupid 对行进行物理分组
- 我想在该组下方动态添加一行,仅包含该组的损益小计。
因此,每个组可以包含许多行,并且每个组都有一个小计行,用于将该组的所有利润/损失相加。我只是想确保小计行始终位于该组中最后一行的正下方。
每当有人向我的表添加新行时,我都需要能够执行此操作(我允许他们通过 UI 动态添加新行)。也就是说,如果有人添加一个新行并为其指定 groupid 3,那么此时我需要将该行与其他 groupid 3 行粘贴在一起,并将其包含在小计计算中。
I am creating a stock portfolio. Each row is a stock and it's data including profit/loss. each row has a groupid that the user can specify. The idea is I want to:
- physically group the rows based on the groupid
- after step #1 I want to dynamically add a row below that group with the subtotal of the profit/losses for that group only.
So each group can contain many rows, and each group will have one subtotal row that adds up all the profit/losses for that group. I just want to make sure that subtotal row is always right below the last row in that group.
I will need to be able to do this whenever someone adds a new row to my table (I allow them to dynamically add new rows through the UI). that is, if someone adds a new row and gives it a groupid of 3, I need to at that moment stick that row with the other groupid 3 rows and include it in the subtotal calculation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
元素对表格行进行分组。
和:
Use
<tbody>
elements to group table rows.with: