Jump to bookmark with code in ReportViewer

2 posts, 0 answers
  1. Sascha
    Sascha avatar
    4 posts
    Member since:
    Dec 2018

    Posted 20 Dec 2018 Link to this post

    I am embedding the ReportViewer in a WPF application. I have a very long report and I want to provide an easy way for the user to navigate in the report.

     

    To achieve an integrated feeling for the user, I'd like to add some buttons to the application that allow the user to jump to certain bookmarks within the report. I cannot use the current page for the purpose, because the length of the sections is dynamic.

     

    I found two older threads with a similar requirement, but they were not really solved by Telerik:

    https://www.telerik.com/forums/navigate-to-a-bookmark-through-code

    https://www.telerik.com/forums/navigating-to-bookmark-from-code

     

    Is there some active development regarding this? Or any workaround? If there were events during rendering that allowed me to capture the report page of every bookmark, this would be sufficient. But I couldn't find anything like this.

     

    I am also fine with calling internal methods using reflection if that's a quick workaround, because I need the functionality very soon.

     

    Thanks,

    Sascha

  2. Ivan Hristov
    Admin
    Ivan Hristov avatar
    191 posts

    Posted 28 Dec 2018 Link to this post

    Hello Sascha,

    Unfortunately this functionality is not yet supported. The bookmark navigation is handled internally and there are no exposed methods to control it. I can suggest to log this feature in our Feedback & Ideas portal and see how the community will vote for it. The users demand for a specific feature will allow us to determine its priority and schedule it for implementation in a future release of our product.

    However, these private methods can be accessed via reflection as the following code demonstrates:
    private void btnNavigateToBookmark_Click(object sender, RoutedEventArgs e)
    {
        var bookmark = this.tbBookmark.Text.Trim(); //the bookmark text to navigate to.
        var modelPropInfo = typeof(Telerik.ReportViewer.Wpf.ReportViewer)
                                .GetProperty("Model", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        var model = modelPropInfo.GetValue(this.ReportViewer1, null);           
        var navigateMethodInfo = model.GetType().GetMethod("NavigateToBookmark",
                                                            System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic,
                                                            Type.DefaultBinder,
                                                            new[] { typeof(string) },
                                                            null );
        navigateMethodInfo.Invoke(model, new[] { bookmark });
    }

    I'm sure you understand the possible problems that may occur when using reflection, but I want to emphasize again that the methods called in this code snippet are intended for internal use only and may change in a future release of our product, making the above code unusable.

     If you have further questions, please let us know.

    Regards,
    Ivan Hristov
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top