How to: Update Total Summaries on the Client Side in Batch Edit Mode
The following example updates total summaries on the client side when ASPxCardView is in Batch Edit mode.
<script type="text/javascript">
function OnBatchEditEndEditing(s, e) {
var originalValue = s.batchEditApi.GetCellValue(e.visibleIndex, "UnitPrice");
var newValue = e.cardValues[(s.GetColumnByField("UnitPrice").index)].value;
var dif = newValue - originalValue;
labelSum.SetValue((parseFloat(labelSum.GetValue()) + dif).toFixed(1));
}
</script>
<dx:ASPxCardView ID="ASPxCardView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" KeyFieldName="ProductID">
<SettingsEditing Mode="Batch" />
<Settings ShowTitlePanel="true" />
<Templates>
<TitlePanel>
Sum =
<dx:ASPxLabel ID="ASPxLabel1" runat="server"
ClientInstanceName="labelSum"
Text='<%# GetTotalSummaryValue() %>' />
</TitlePanel>
</Templates>
<Columns>
<dx:CardViewTextColumn FieldName="ProductID" Visible="False">
<dx:CardViewTextColumn FieldName="ProductName" />
<dx:CardViewTextColumn FieldName="UnitPrice" />
<dx:CardViewTextColumn FieldName="UnitsInStock" />
<dx:CardViewTextColumn FieldName="UnitsOnOrder" />
</Columns>
<ClientSideEvents BatchEditEndEditing="OnBatchEditEndEditing" />
<TotalSummary>
<dx:ASPxCardViewSummaryItem SummaryType="Sum" FieldName="UnitPrice" />
</TotalSummary>
</dx:ASPxCardView>
protected object GetTotalSummaryValue() {
ASPxCardViewSummaryItem summaryItem = ASPxCardView1.TotalSummary.First(i => i.FieldName == "UnitPrice");
return ASPxCardView1.GetTotalSummaryValue(summaryItem);
}
protected void ASPxLabel1_Init(object sender, EventArgs e) {
var label = (ASPxLabel)sender;
label.DataBind();
}