'DevExpress GridView Summary Update Sum Footer When 2nd Row Added
My GridView Summary on Footer not updated when I add First Row.
My Code
Item.SummaryType = SummaryItemType.Count
Item.DisplayFormat = "{0} Item"
TotalPrice.SummaryType = SummaryItemType.Sum
DataTabel = New DataTable
With DataTabel
.Columns.Add("ItemCode")
.Columns.Add("ItemName")
.Columns.Add("Category")
.Columns.Add("Quantity", GetType(Decimal))
.Columns.Add("Unit")
.Columns.Add("PriceCode")
.Columns.Add("Price", GetType(Double))
.Columns.Add("TotalPrice", GetType(Double), "Quantity * Price")
End With
GridControl1.DataSource = DataTabel
With GridView1
.OptionsView.NewItemRowPosition = Views.Grid.NewItemRowPosition.Bottom
.OptionsView.ShowFooter = True
.OptionsCustomization.AllowColumnMoving = False
.OptionsCustomization.AllowSort = False
.OptionsSelection.EnableAppearanceFocusedRow = False
.Columns(0).Caption = "Code Item"
.Columns(0).ColumnEdit = RepoKodeBarang
.Columns(1).Caption = "Item Name"
.Columns(1).OptionsColumn.ReadOnly = True
.Columns(1).OptionsColumn.TabStop = False
.Columns(1).OptionsColumn.AllowEdit = False
.Columns(2).Caption = "Category"
.Columns(2).OptionsColumn.ReadOnly = True
.Columns(2).OptionsColumn.TabStop = False
.Columns(2).OptionsColumn.AllowEdit = False
.Columns(3).Caption = "Quantity"
.Columns(3).ColumnEdit = RepoQuantity
.Columns(3).Summary.Add(Item)
.Columns(4).Caption = "Unit"
.Columns(4).OptionsColumn.ReadOnly = True
.Columns(4).OptionsColumn.TabStop = False
.Columns(4).OptionsColumn.AllowEdit = False
.Columns(5).Caption = "Price Code"
.Columns(5).ColumnEdit = RepoKodeHarga
.SetRowCellValue(GridView1.FocusedRowHandle, "PriceCode", 3)
.Columns(6).Caption = "Price"
.Columns(7).Caption = "Total Price"
.Columns(7).OptionsColumn.ReadOnly = True
.Columns(7).OptionsColumn.TabStop = False
.Columns(7).OptionsColumn.AllowEdit = False
.Columns(7).Summary.Add(TotalPrice)
End With
If I add First Row, With Total Price Are 5.000 the summary still show blank, but if I add second row with Total Price 2.500 the summary will work and change to 7.500..
Screenshot After 1st Row Added
Screenshot After 2nd Row Added
Did I miss something?
And by the way. All input happen in cell directly. Thanks
Update #01 - If I Change the SummaryType to Count. It Will Work After 1st Row Added. But if I change back to Sum. It Doesnt Work.
Update #02 - It does not work if I use
.Columns.Add("TotalPrice", GetType(Double), "Quantity * Price")
If I change to this, then it will works
.Columns.Add("TotalPrice", GetType(Double))
Solution 1:[1]
I used to have the same issue and I solve it by using the Event:
Gridview.ValidatingEditor
In my case i was checking if the input was Numeric with the code below:
Private Sub Gridview_ValidatingEditor(sender As Object, e As BaseContainerValidateEditorEventArgs) Handles Gridview.ValidatingEditor
If Not IsNumeric(e.Value) Then
e.Valid = False
e.ErrorText = "Error"
End If
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | S3minaki |
