Refresh RadGrid

5 posts, 0 answers
  1. pierre-jean
    pierre-jean avatar
    149 posts
    Member since:
    Apr 2011

    Posted 21 Nov 2016 Link to this post

    I use the following function to load Horse names starting with a given letter

    The first call returns and displays the list in the grid view

    But at the second and following calls, while the HorseList is correctly generated, the display in the grid does not display the new list

    I know that this questionhas been discussed many times but I have not found the solution .....

    Thanks in advance

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------

          Public Function LoadNode(ByVal FirstLetter As String) As Boolean
            Try
                Dim aHorse As New mHorse
                Dim Horses As New List(Of Horse)
                'Load the Horses list where the name starts with "FirstLetter"
                Horses = aHorse.LoadNode(FirstLetter)
                If Horses.Count > 0 Then
                    gvHorse.BeginUpdate()
                    gvHorse.DataSource = Horses
                    gvHorse.EndUpdate()
                Else

                End If
            Catch ex As Exception

            End Try
        End Function

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4086 posts

    Posted 22 Nov 2016 Link to this post

    Hello Pierre-Jean,

    Thank you for writing.  

    RadGridView is capable of fetching bindable properties and data. However, one important issue must be noted: during the data binding process, the grid extracts the data from the data source, but for any later changes in the data source, RadGridView should be notified. Your bindable collection and business objects should follow some standards established in .NET in order to notify RadGridView about the changes. The following help article is quite useful on this topic: http://docs.telerik.com/devtools/winforms/gridview/populating-with-data/reflecting-custom-object-changes-in-rgv

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
  3. pierre-jean
    pierre-jean avatar
    149 posts
    Member since:
    Apr 2011

    Posted 22 Nov 2016 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hello Dess

    Thanks for your reply that gives me the direction of the solution.

    I have spent a considerable amount of time reading and trying but I have not been able to implement the solution, i.e. how to generate a bindable list

    I understand that my question is not strictly speaking a "telerik issue", however if you coud tell me how to modifiy the below code to generate a bindable object from my entityframework context I would be extremely gratefull (or if you have a simple example)

    --------------------------------------------------------------------------------------------------------

    HorseListe as list(of Horse) =  (From aHorse As Horse In context.Horses Where aHorse.CurrentName.StartsWith(FirstLetter)  Order By aHorse.CurrentName).ToList()

    -------------------------------------------------------------------------------------------------------

    Thanks a lot

     

  4. pierre-jean
    pierre-jean avatar
    149 posts
    Member since:
    Apr 2011

    Posted 23 Nov 2016 in reply to pierre-jean Link to this post

    OK this solved the problem:

     

        Public Function GetHorses(startChar As String) As BindingList(Of Horse)
            Dim context As New WJSQLEntities
            Dim query = (From aHorse As Horse In context.Horses Where aHorse.CurrentName.StartsWith(startChar) Order By aHorse.CurrentName)
            Return New BindingList(Of Horse)(query.ToList)
        End Function

  5. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4086 posts

    Posted 24 Nov 2016 Link to this post

    Hello Pierre-Jean, 

    Thank you for writing back. 

    I am glad that the problem you were facing is now resolved. The following help article demonstrates how to bind RadGridView to EntityFramework: http://docs.telerik.com/devtools/winforms/gridview/populating-with-data/binding-to-entityframework-using-database-first-approach

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
Back to Top