Skip to content

Commit 5120460

Browse files
authored
update description (#6)
* update description * Update Readme.md
1 parent 670659e commit 5120460

File tree

3 files changed

+55
-17
lines changed

3 files changed

+55
-17
lines changed

Readme.md

+52-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,60 @@
1-
<!-- default badges list -->
2-
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/128532799/18.2.3%2B)
3-
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T116925)
4-
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
5-
<!-- default badges end -->
6-
<!-- default file list -->
7-
*Files to look at*:
8-
9-
* **[Default.aspx](./CS/Default.aspx) (VB: [Default.aspx.vb](./VB/Default.aspx.vb))**
10-
* [Default.aspx.cs](./CS/Default.aspx.cs) (VB: [Default.aspx.vb](./VB/Default.aspx.vb))
11-
<!-- default file list end -->
12-
# ASPxGridView - Batch Edit - How to calculate unbound column and total summary values on the fly
1+
# Grid View for ASP.NET Web Forms - How to calculate values and update total summaries dynamically in batch edit mode
132
<!-- run online -->
143
**[[Run Online]](https://codecentral.devexpress.com/t116925/)**
154
<!-- run online end -->
165

17-
<p>Starting with v18.2 we support callbacks and keep the changes safe while a user navigates via pages, filters and sorts the grid data. If you use this version and above, please copy/clone the 18.2.3+ branch as approaches to update total summaries differ in new versions and old ones. </p>
6+
This example demonstrates how to create an unbound column that changes its values based on other column values and replace summary items with custom footer templates to calculate total summaries dynamically in batch edit mode. This example combines the following approaches:
7+
* [How to calculate values dynamically in batch edit mode](https://github.com/DevExpress-Examples/asp-net-web-forms-gridview-calculate-values-dynamically-batch-mode)
8+
* [How to update total summaries on the client in batch edit mode](https://github.com/DevExpress-Examples/asp-net-web-forms-grid-update-total-summaries-on-client-in-batch-mode)
9+
10+
![Update column values and calculate total summaries](calculateValues.png)
11+
12+
## Overview
13+
14+
Follow the steps below to calculate column values and update total summaries on the client in batch edit mode:
15+
16+
1. Add total summary items for the corresponding columns. Use the item's [Tag](https://docs.devexpress.com/AspNet/DevExpress.Web.ASPxSummaryItemBase.Tag) property to identify the summary item and get its value.
17+
18+
```aspx
19+
<TotalSummary>
20+
<dx:ASPxSummaryItem SummaryType="Sum" FieldName="Mon" Tag="Mon_Sum" />
21+
<dx:ASPxSummaryItem SummaryType="Sum" FieldName="Tue" Tag="Tue_Sum" />
22+
<dx:ASPxSummaryItem SummaryType="Sum" FieldName="Wen" Tag="Wen_Sum" />
23+
<dx:ASPxSummaryItem SummaryType="Sum" FieldName="Total" Tag="Total_Sum" />
24+
</TotalSummary>
25+
```
26+
27+
```cs
28+
protected object GetSummaryValue(string fieldName) {
29+
ASPxSummaryItem summaryItem = Grid.TotalSummary.First(i => i.Tag == fieldName + "_Sum");
30+
return Grid.GetTotalSummaryValue(summaryItem);
31+
}
32+
```
33+
34+
2. Set the unbound column's [ShowEditorInBatchEditMode](https://docs.devexpress.com/AspNet/DevExpress.Web.GridDataColumnSettings.ShowEditorInBatchEditMode) property to `false` to make the column read-only in batch edit mode. Replace all summary items with custom [footer templates](https://docs.devexpress.com/AspNet/DevExpress.Web.GridViewColumn.FooterTemplate).
35+
36+
```aspx
37+
<dx:GridViewDataTextColumn FieldName="Total" UnboundType="Decimal" ReadOnly="true">
38+
<Settings ShowEditorInBatchEditMode="false" />
39+
<FooterTemplate>
40+
<dx:ASPxLabel ID="ASPxLabel1" runat="server" ClientInstanceName="labelTotal"
41+
Text='<%# GetSummaryValue((Container.Column as GridViewDataColumn).FieldName) %>' />
42+
</FooterTemplate>
43+
</dx:GridViewDataTextColumn>
44+
```
45+
46+
3. Handle the grid's client-side [BatchEditEndEditing](https://docs.devexpress.com/AspNet/js-ASPxClientGridView.BatchEditEndEditing), [BatchEditRowDeleting](https://docs.devexpress.com/AspNet/js-ASPxClientGridView.BatchEditRowDeleting), and [BatchEditRowRecovering](https://docs.devexpress.com/AspNet/js-ASPxClientGridView.BatchEditRowRecovering) events to recalculate unbound column values and total summaries. Call the grid's [batchEditApi.GetCellValue](https://docs.devexpress.com/AspNet/js-ASPxClientGridViewBatchEditApi.GetCellValue(visibleIndex-columnFieldNameOrId)) method to get initial cell values and the [batchEditApi.SetCellValue](https://docs.devexpress.com/AspNet/js-ASPxClientGridViewBatchEditApi.SetCellValue(visibleIndex-columnFieldNameOrId-value)) method to assign new values to the unbound column.
47+
48+
## Files to Review
49+
50+
* [Default.aspx](./CS/Default.aspx) (VB: [Default.aspx.vb](./VB/Default.aspx.vb))
51+
* [Default.aspx.cs](./CS/Default.aspx.cs) (VB: [Default.aspx.vb](./VB/Default.aspx.vb))
1852
19-
<p>This example illustrates how to calculate unbound column and total summary values on the fly. It combines the following two examples: <a href="https://www.devexpress.com/Support/Center/p/T114923">ASPxGridView - How to update total summaries on the client side in Batch Edit mode</a> and <a href="https://www.devexpress.com/Support/Center/p/T114539">ASPxGridView - Batch Edit - How to calculate values on the fly</a>.<br /><br /><strong>ASP.NET MVC Example:</strong><br /><a href="https://www.devexpress.com/Support/Center/p/T124151">GridView - Batch Edit - How to calculate unbound column and total summary values on the fly</a> </p>
53+
## Documentation
2054
21-
<br/>
55+
* [Grid in Batch Edit Mode](https://docs.devexpress.com/AspNet/16443/components/grid-view/concepts/edit-data/batch-edit-mode)
56+
* [Grid View Templates](https://docs.devexpress.com/AspNet/3718/components/grid-view/concepts/templates)
2257
58+
## More Examples
2359
60+
* [Grid View for ASP.NET MVC - How to calculate values and update total summaries dynamically in batch edit mode](https://github.com/DevExpress-Examples/gridview-batch-edit-how-to-calculate-unbound-column-and-total-summary-values-on-the-fly-t124151)

calculateValues.png

36.4 KB
Loading

config.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"runOnWeb": true,
3-
"autoGenerateVb": true
4-
}
3+
"autoGenerateVb": true,
4+
"useLegacyVbConverter": true
5+
}

0 commit comments

Comments
 (0)