How To Add Text Total In Summary Footer Aspxgridview
Files to look at:
- HomeController.cs (VB: HomeController.vb)
- Model.cs (VB: Model.vb)
- _GridViewPartial.cshtml
- Alphabetize.cshtml
GridView - How to update total summaries on the customer side in Batch Edit fashion
[Run Online]
Starting with v18.2 we back up callbacks and go on the changes prophylactic while a user navigates via pages, filters and sorts the grid data. If y'all use this version and above, please copy the eighteen.two.3+ branch as approaches to update summaries differ in new versions and old ones.
This case demonstrates how to update total summaries on the customer side when GridView is in Batch Edit mode.
Clarification
1. Add together a total summary detail for a required column. The Tag property is used to find this summary item and get its value:
settings.Columns.Add together(column => { column.FieldName = "C2" ; column.ColumnType = MVCxGridViewColumnType.SpinEdit; ASPxSummaryItem summaryItem = new ASPxSummaryItem(column.FieldName, DevExpress.Data.SummaryItemType.Sum); summaryItem.Tag = cavalcade.FieldName + "_Sum" ; summaryItem.DisplayFormat = "{0}" ; settings.TotalSummary.Add together(summaryItem); });
2. Supplant the summary particular with a custom Footer template:
column.SetFooterTemplateContent(c => { Html.DevExpress().Label(lbSettings => { string fieldName = (c.Cavalcade equally GridViewDataColumn).FieldName; lbSettings.Proper name = "labelSum" ; lbSettings.Backdrop.EnableClientSideAPI = truthful; ASPxSummaryItem summaryItem1 = c.Grid.TotalSummary.First(i => i.Tag == (fieldName + "_Sum" )); lbSettings.Text = c.Grid.GetTotalSummaryValue(summaryItem1).ToString(); }).Render(); });
3. Handle the ASPxClientGridView.BatchEditRowDeleting , ASPxClientGridView.BatchEditEndEditing , ASPxClientGridView.BatchEditChangesCanceling events to recalculate summary.
function OnBatchEditEndEditing ( south , e ) { CalculateSummary ( due south , e . rowValues , east . visibleIndex , false ) ; } function CalculateSummary ( grid , rowValues , visibleIndex , isDeleting ) { var originalValue = grid . batchEditApi . GetCellValue ( visibleIndex , "C2" ) ; var newValue = rowValues [ ( filigree . GetColumnByField ( "C2" ) . index ) ] . value ; var dif = isDeleting ? - newValue : newValue - originalValue ; labelSum . SetValue ( ( parseFloat ( labelSum . GetValue ( ) ) + dif ) . toFixed ( 1 ) ) ; } role OnBatchEditRowDeleting ( s , e ) { CalculateSummary ( south , e . rowValues , e . visibleIndex , true ) ; } role OnChangesCanceling ( s , e ) { if ( s . batchEditApi . HasChanges ( ) ) setTimeout ( function ( ) { due south . Refresh ( ) ; } , 0 ) ; }
How To Add Text Total In Summary Footer Aspxgridview,
Source: https://github.com/DevExpress-Examples/gridview-how-to-update-total-summaries-on-the-client-side-in-batch-edit-mode-t137186
Posted by: lohmanmrsed2001.blogspot.com
0 Response to "How To Add Text Total In Summary Footer Aspxgridview"
Post a Comment