Skip to content

Export filename and export format types#197

Open
jonokhor wants to merge 2 commits intoilich:masterfrom
medhealth:export-filename-and-export-format-types
Open

Export filename and export format types#197
jonokhor wants to merge 2 commits intoilich:masterfrom
medhealth:export-filename-and-export-format-types

Conversation

@jonokhor
Copy link

Resolves #162.
Resolves #144.

This is what we're currently using at my company. With #144, a decision was made to specify the export format types to display rather than the types to hide because it is more useful to us to specify it that way.

Happy to take any feedback.

@jk464479460
Copy link

Thanks for fixing this issue. But I found one issue for specific format types.
Test Data:
var ctrlSetting = new ControlSettings() { VisibleExportFormats=new ReportFormat[] { ReportFormat.Pdf, ReportFormat.Word, ReportFormat.ExcelOpenXml} };
...
@Html.MvcReportViewer(...).ControlSettings(ctrlSetting);
Test Result:
Word will didn't show in export list.
I change ReportViewerExtensions.cs,
` private static void HideRenderingExtensions(Report report, ControlSettings controlSettings)
{

        report.ListRenderingExtensions().ToList().ForEach(item=> {
            if (controlSettings.VisibleExportFormats.Count(i=>i.ToString().ToUpper()==item.Name.ToUpper())>0)
            {
                var isVisiblePrivateField = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                if (isVisiblePrivateField != null)
                {
                    isVisiblePrivateField.SetValue(item, true);
                }
            }
            else
            {
                var isVisiblePrivateField = item.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                if (isVisiblePrivateField != null)
                {
                    isVisiblePrivateField.SetValue(item, false);
                }
            }
        });

        //var hiddenRenderingExtensions = report.ListRenderingExtensions()
        //        .Where(renderingExtension =>
        //            controlSettings.VisibleExportFormats.All(exportFormat =>
        //            !renderingExtension.Name.EqualsIgnoreCase(exportFormat.ToString())));

        //foreach (var renderingExtension in hiddenRenderingExtensions)
        //{
        //    var isVisiblePrivateField = renderingExtension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
        //    if (isVisiblePrivateField != null)
        //    {
        //        isVisiblePrivateField.SetValue(renderingExtension, false);
        //    }
        //}
    }`

It will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants