We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SortColumnsChanged list view before sort

Using version v19.2.0.44


When SortColumnsChanged event is fired and then looping through the records, they are presented in the order before the sort and not after sort

For Each record In sfd_Documents.View.Records

docID = record.Data(0)

Next record


4 Replies

MA Martin October 7, 2022 04:30 PM

I have updated to v20.3.0.47 and the issue persists.


    Private Sub sfd_Documents_SortColumnsChanged(ByVal sender As Object, ByVal e As SortColumnsChangedEventArgs)

        For Each record In sfd_Documents.View.Records

            docID = record.Data(0)

        Next record

    End Sub


The first record is the first record before the sort.



DM Dhanasekar Mohanraj Syncfusion Team October 10, 2022 09:00 AM

Hi Martin,

We have checked the reported issue with the provided details. By default, the SfDataGrid.SortColumnsChanged event is triggered once the sorted columns get changed. At that moment the view does not update completely that why the reported issue occurs. However, you can achieve your requirement by using the below code snippet,


AddHandler sfDataGrid1.SortColumnsChanged, AddressOf OnSortColumnsChanged

Private Sub OnSortColumnsChanged(ByVal sender As Object, ByVal e As SortColumnsChangedEventArgs)

    Me.sfDataGrid1.BeginInvoke(New Action(Sub()

                                              For Each record In Me.sfDataGrid1.View.Records

                                                  Dim data = record.Data

                                              Next record

                                          End Sub))

End Sub


We have prepared the sample based on your requirement. Please have a look at this, and revert us if you have any concerns about this.

Regards,
Dhanasekar M.


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: VB_Demo_33fd18ec.zip


MA Martin October 10, 2022 09:58 AM

Hi  Dhanasekar,

Unfortunately I get the following error when inserting into my code:


Error.jpg



DM Dhanasekar Mohanraj Syncfusion Team October 11, 2022 10:37 AM

Hi Martin,

We have checked the reported issue on our end. In that, the provided code snippet worked properly as expected on our end. Here we have attached the tested video demo for your reference please have a look at this. Seems it may be the compiler issue, could you please clean and rebuild the application it may resolve the reported issue. If you still facing the reported issue remove the code snippet and entered
your code snippet it manually inside the BeginInvoke method shown below,

 Me.sfDataGrid1.BeginInvoke(New Action(Sub()

End Sub))



It will resolve the reported issue. Please check and revert us if you need further assistance with this.

Regards,
Dhanasekar M.


Attachment: Tested_Video_e5de3fdd.zip

Loader.
Live Chat Icon For mobile
Up arrow icon