summary row value move to textbox

7 posts, 1 answers
  1. Hengky
    Hengky avatar
    67 posts
    Member since:
    Sep 2015

    Posted 05 Oct 2020 Link to this post

    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 

  2. Nadya
    Admin
    Nadya avatar
    481 posts

    Posted 07 Oct 2020 Link to this post

    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/.

  3. Hengky
    Hengky avatar
    67 posts
    Member since:
    Sep 2015

    Posted 14 Oct 2020 in reply to Nadya Link to this post

    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 ..

  4. Nadya
    Admin
    Nadya avatar
    481 posts

    Posted 14 Oct 2020 Link to this post

    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).

  5. Hengky
    Hengky avatar
    67 posts
    Member since:
    Sep 2015

    Posted 15 Oct 2020 in reply to Nadya Link to this post

    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... 

  6. Answer
    Nadya
    Admin
    Nadya avatar
    481 posts

    Posted 15 Oct 2020 Link to this post

    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).

  7. Hengky
    Hengky avatar
    67 posts
    Member since:
    Sep 2015

    Posted 18 Oct 2020 in reply to Nadya Link to this post

    tq nad ... 

    it's work very2 fine ... 

     

    tq tq

Back to Top