EnsureVisible miss his target with a newrow

8 posts, 0 answers
  1. Marco
    Marco avatar
    87 posts
    Member since:
    Apr 2011

    Posted 18 Dec 2014 Link to this post

    Hello Telerik

    I have a little issue on adding row to a gridview using a objectquery(Of T) as datasource. The gridview is groupped on two level (fixed by design). Rows are added programmatically on a button click event with the following code.

    Private Sub AddNew_Click(sender As System.Object, e As System.EventArgs) Handles AddNew.Click
            Try
                'Add a new row
                Dim newrow As GridViewRowInfo = Me.NotesFrais.Rows.AddNew()
     
                'Set default value on the new data object
                Dim newnotedefrais As NoteFrais = CType(newrow.DataBoundItem, NoteFrais)
     
                With newnotedefrais
                    .DateCreation = Today.Date
     
                    Dim currentuserguid As Guid = GetCurrentUser.Guid
                    Dim currentcollaborateur As Collaborateur = Me._datactx.Collaborateur.Single(Function(c) c.AD_Guid.Equals(currentuserguid))
                    .Collaborateur = currentcollaborateur
     
                    .IsTemporaire = True
                End With
     
                'Update the database
                Me._datactx.SaveChanges()
     
                'Select the new row
                newrow.EnsureVisible(True)
                newrow.IsSelected = True
                newrow.IsExpanded = True
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Une erreur est survenue..")
            End Try
        End Sub

    The issue is that's the EnsureVisible do not expend the good group (on the yellow one on the picture).  If the "good" group is expended before the sub, all is goning fine (EnsureVisible do not expand the wrong group).

  2. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 23 Dec 2014 Link to this post

    Hello Marco,

    Thank you for writing.

    I have prepared a sample project in which I have established a connection to a small database using EntityFramework. I have successfully added new rows with data when the grid is grouped and the EnsureRow seems to be working correctly. I would suggest that you also invoke InvalidateRow method to have the data refreshed as soon as the new row is added.

    I am sending you attached my project, as well as a .gif file showing how the grid looks on my side. Can you please let me know what I am missing?

    Regards,
    Hristo
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marco
    Marco avatar
    87 posts
    Member since:
    Apr 2011

    Posted 23 Dec 2014 in reply to Hristo Link to this post

    Hello Hristo,

    Thank you for the answer.

    I will check your sample and if I don't find my solution in it. I would post back a sample project to reproduce this issues, certainly after Christmas break.

    Best wishes
  5. Marco
    Marco avatar
    87 posts
    Member since:
    Apr 2011

    Posted 07 Jan 2015 Link to this post

    Hello Hristo,

    I came back about this problem. First of all thanks for the sample project.

    Don't really know why it's not working fine with my project.

    Perhaps it's because I'm using two level for grouping (The first level work fine, the problem is about the second level of group, your sample use only one level of grouping perhaps you should try with two group descriptor (something like people grouped by country and gender)).

    As the EnsureVisible works fine if the "right" groups are expanded, I expand them manually before calling EnsureVisible. It's an acceptable workaround.

    Thanks for you support
  6. Marco
    Marco avatar
    87 posts
    Member since:
    Apr 2011

    Posted 07 Jan 2015 Link to this post

    Hello Hristo,

    Thank for your sample project.

    Invoking InvalidateRow is not helping but expending the group before calling EnsureVisible is making the trick.

    You should perhaps try with two level of grouping (something like people grouped by country and gender) because the issue is coming over the second level of grouping in my project.

    As I have found an acceptable workaround, I will move to the next topic of my fine tuning ToDoList.
  7. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 12 Jan 2015 Link to this post

    Hi Marco,

    Thank you for writing back.

    I am glad that you found an acceptable workaround. However I am unable to reproduce this behavior on my side. 

    Please find attached my sample project with two level grouping. I am also sending you a .gif file showing how the grid looks on my side.

    If you could provide with more details regarding your scenario I would be happy to examine it further and determine if we had an issue with our control.

    Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. Marco
    Marco avatar
    87 posts
    Member since:
    Apr 2011

    Posted 12 Jan 2015 in reply to Hristo Link to this post

    Hi Hristo,

    Thanks for the update.

    I will be really happy to make a test project with this issue but the form is quite complex and had some dependencies. So I couldn't make a simple copy paste for the sample. I will keep a post-if in one of the corner of my screen about building a sample app but as I found a workaround you will understand that I won't put an high priority on it.

    Either way it's actually working that's the main subject after all. Quality and feedback could wait a few day!

    Have a nice day.
  9. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 15 Jan 2015 Link to this post

    Hello Marco,

    Good luck with your project.

    Feel free to contact us again anytime regarding the issue you described. I would be happy to further investigate it.

    Also any other questions regarding our controls are always welcome.

    Regards,
    Hristo
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready