gpt4 book ai didi

javascript - GridPanel CheckboxSelectionModel - 所选总和

转载 作者:行者123 更新时间:2023-12-03 02:52:15 26 4
gpt4 key购买 nike

如何对所有选定行的特定列求和? (通过 JavaScript)

    <script>
var sumCheck= function () {
var resultSum;

/* todo loop selectedrows
resultSum += column(nvlparmvfin); */;

alert(resultSum);
};
</script>

<ext:GridPanel runat="server" ID="grid1" Height="250px" Frame="true" StoreID="dsGrid1">
<ColumnModel runat="server">
<Columns>
<ext:NumberColumn runat="server" DataIndex="nvlparmvfin" Format=",0.00" Align="Right"/>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" Mode="Multi">
<Listeners>
<SelectionChange Fn="sumCheck()" />
</Listeners>
</ext:CheckboxSelectionModel>
</SelectionModel>
</ext:GridPanel>

如果您能帮助我,非常感谢;

最佳答案

您必须遍历所选记录的循环,然后存储特定列的值并将其放入计数中。

你的代码将类似于这样

var grd = this.up().up();
var gridSel = grd.getSelection();
var count = 0;
for(var i=0; i<gridSel.length;i++){
var num = gridSel[i].data.indexSum;
num = parseInt(num);
count += num;
}
alert(count);

我为你创建了一个 fiddle 。请检查。

Fiddle

关于javascript - GridPanel CheckboxSelectionModel - 所选总和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47799852/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com