This is a migrated thread and some comments may be shown as answers.

summary row value move to textbox

6 Answers 468 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hengky
Top achievements
Rank 1
Veteran
Hengky asked on 05 Oct 2020, 09:21 AM

Hello all.. 

how to populate the summary sum in summary row to textbox ... when summaryrow visible is false .. 

I have wrote this code ... 

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        Dim summaryItem As New GridViewSummaryItem()
        summaryItem.Name = "Nilai"
        summaryItem.Aggregate = GridAggregateFunction.Sum
        Dim summaryRowItem As New GridViewSummaryRowItem()
        summaryRowItem.Add(summaryItem)
        Me.GridDetail.SummaryRowsBottom.Add(summaryRowItem)
        Me.GridDetail.MasterView.SummaryRows(0).IsVisible = False
    End Sub

    Private Sub GridDetail_SummaryEvaluate(sender As Object, e As GroupSummaryEvaluationEventArgs) Handles GridDetail.GroupSummaryEvaluate
        TxtTotal.Value = e.Value
    End Sub

this code is working fine ... to deliver the value from summary row to textbox  if visible of summaryrow = true 

how make the value from summary row to textbox when visible is false 

6 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 07 Oct 2020, 12:19 PM

Hello, Hengky,

If I understand your requirement correctly you would like to hide the summary row but still be able to get the calculated value and show it in a text box. If you set IsVisible of the summary row to false, the GroupSummaryEvaluate shouldn't fire. This is why in this case I would suggest using the GetSummary method as demonstrated below:

 Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
     Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)

     Dim summaryItem As New GridViewSummaryItem()
     summaryItem.Name = "ContactName"
     summaryItem.Aggregate = GridAggregateFunction.Count
     Dim summaryRowItem As New GridViewSummaryRowItem()
     summaryRowItem.Add(summaryItem)
     Me.RadGridView1.SummaryRowsBottom.Add(summaryRowItem)
     Me.RadGridView1.MasterView.SummaryRows(0).IsVisible = False
     Dim DataColumn = TryCast(Me.RadGridView1.Columns(2), GridViewDataColumn)

     Dim value = Me.RadGridView1.MasterView.SummaryRows(0).GetSummary(DataColumn)
      Me.RadTextBox1.Text = value
 End Sub

I hope this helps. If you need further assistance please let me know.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Hengky
Top achievements
Rank 1
Veteran
answered on 14 Oct 2020, 07:15 AM

Hello nadya ... 

I have test the code that u gave to me... 

it still doesn't work .. 

i just need to sum on run the code ... every change the value of Nilai it will automatic sum .. 

 

tq nad ..

0
Nadya | Tech Support Engineer
Telerik team
answered on 14 Oct 2020, 02:03 PM

Hello, Hengky,

You can handle the CellEndEdit event which fires every time when cell editing is finished and the new value is committed to the cell. In this event, you can get the result from the GetSummary method. Thus, any time a cell value from the column is updated you will get the new result for the summary row.

More information about the editing event is the grid is available here: https://docs.telerik.com/devtools/winforms/controls/gridview/insert-update-delete-records/data-editing-event-sequence 

I hope this helps. If you need further assistance do not hesitate to contact me.

Regards,
Nadya
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Hengky
Top achievements
Rank 1
Veteran
answered on 15 Oct 2020, 05:59 AM

Hello Nadya .. thanks for replying ... 

this code i wrote ... 

    Private Sub GridDetail_CellEndEdit(sender As Object, e As GridViewCellEventArgs) Handles GridDetail.CellEndEdit
        If e.Column.Name = "Qtty" Or e.Column.Name = "Harga" Then
            Dim summaryItem As New GridViewSummaryItem()
            summaryItem.Name = "Nilai"
            summaryItem.Aggregate = GridAggregateFunction.Sum
            Dim summaryRowItem As New GridViewSummaryRowItem()
            summaryRowItem.Add(summaryItem)
            Me.GridDetail.SummaryRowsBottom.Add(summaryRowItem)
            Me.GridDetail.MasterView.SummaryRows(0).IsVisible = False


            Dim DataColumn = TryCast(Me.GridDetail.Columns(5), GridViewDataColumn)
            Dim value = Me.GridDetail.MasterView.SummaryRows(0).GetSummary(DataColumn)
            Me.TxtTotal.Text = value
        End If

    End Sub

summaryrows still show... 

0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 15 Oct 2020, 05:03 PM

Hello, Hengky,

I updated my project in order to demonstrate how you can track the cell value changes and update the result that is shown in the text box field. Please refer to the following code snippet which result is demonstrated in the attached gif file.

Public Class RadForm1
    Dim DataColumn
    Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products)

        AddHandler RadGridView1.CellEndEdit, AddressOf radGridView1_CellEndEdit

        Dim summaryItem As New GridViewSummaryItem()
        summaryItem.Name = "UnitsInStock"
        summaryItem.Aggregate = GridAggregateFunction.Sum
        Dim summaryRowItem As New GridViewSummaryRowItem()
        summaryRowItem.Add(summaryItem)
        Me.RadGridView1.SummaryRowsBottom.Add(summaryRowItem)
        Me.RadGridView1.MasterView.SummaryRows(0).IsVisible = False

        DataColumn = TryCast(Me.RadGridView1.Columns(2), GridViewDataColumn)
        Dim value = Me.RadGridView1.MasterView.SummaryRows(0).GetSummary(DataColumn)
        Me.RadTextBox1.Text = value
    End Sub

    Private Sub radGridView1_CellEndEdit(ByVal sender As Object, ByVal e As GridViewCellEventArgs)
        Dim value = Me.RadGridView1.MasterView.SummaryRows(0).GetSummary(DataColumn)
        Me.RadTextBox1.Text = value
    End Sub
End Class

I hope this helps. If you need further assistance please let me know.

Regards,
Nadya
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Hengky
Top achievements
Rank 1
Veteran
answered on 19 Oct 2020, 03:26 AM

tq nad ... 

it's work very2 fine ... 

 

tq tq

Tags
GridView
Asked by
Hengky
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Hengky
Top achievements
Rank 1
Veteran
Share this question
or