Coder Social home page Coder Social logo

Comments (5)

danielpalme avatar danielpalme commented on July 19, 2024 1

I'm sorry, but that's a very specific requirement.
You should use a custom report.

This would be the easiest way to solve your problem:

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using Palmmedia.ReportGenerator.Parser.Analysis;
using Palmmedia.ReportGenerator.Properties;
using Palmmedia.ReportGenerator.Reporting;
using Palmmedia.ReportGenerator.Reporting.Rendering;

namespace MyCompany.CustomReportTypes
{
    [System.ComponentModel.Composition.Export(typeof(IReportBuilder))]
    public class CustomHtmlReportBuilder : HtmlReportBuilder
    {
        public override void CreateSummaryReport(SummaryResult summaryResult)
        {
            base.CreateSummaryReport(summaryResult);

            string javascriptPath = Path.Combine(this.TargetDirectory, "combined.js");

            string content = File.ReadAllText(javascriptPath)
                .Replace("grouping: '0',", "grouping: this.getGroupingMaximum(this.props.assemblies),");

            File.WriteAllText(javascriptPath, content);
        }
    }
}

from reportgenerator.

gregveres avatar gregveres commented on July 19, 2024 1

Thank you I will give this a try.

from reportgenerator.

gregveres avatar gregveres commented on July 19, 2024 1

The final solution that I went with is working great with this code for a plugin:

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using Palmmedia.ReportGenerator.Parser.Analysis;
using Palmmedia.ReportGenerator.Properties;
using Palmmedia.ReportGenerator.Reporting;
using Palmmedia.ReportGenerator.Reporting.Rendering;

namespace MyCompany.CustomReportTypes
{
    [System.ComponentModel.Composition.Export(typeof(IReportBuilder))]
    public class ComponentExpandedReportBuilder : HtmlReportBuilder
    {
        public override void CreateSummaryReport(SummaryResult summaryResult)
        {
            base.CreateSummaryReport(summaryResult);

            string javascriptPath = Path.Combine(this.TargetDirectory, "combined.js");

            string content = File.ReadAllText(javascriptPath)
                .Replace("getInitialState: function () {", "getInitialState: function () { var maxGroup = this.getGroupingMaximum(this.props.assemblies);")
                .Replace("grouping: '0',", "grouping: maxGroup,")
                .Replace("groupingMaximum: this.getGroupingMaximum(this.props.assemblies)", "groupingMaximum: maxGroup")
                .Replace("assemblies: this.getAssemblies(this.props.assemblies, '0', '', 'name', 'asc')",
                "assemblies: this.getAssemblies(this.props.assemblies, maxGroup, '', 'name', 'asc')");

            File.WriteAllText(javascriptPath, content);
        }
    }
}

from reportgenerator.

gregveres avatar gregveres commented on July 19, 2024

thanks for the suggestion on this. It doesn't work. I can see that it properly sets the initial value of the grouping variable in the js. And the page does come up with that value as the value for grouping. But the initialization of the page doesn't respect the variable so the result is that I have to switch the grouping to something else, the come back to the max value.

I am going to look through the code to see if I can fix the issue where the page init doesn't respect the initial grouping value.

from reportgenerator.

gregveres avatar gregveres commented on July 19, 2024

Found the problem. The function needs to be changed in two locations:

        return {
            grouping: this.getGroupingMaximum(this.props.assemblies),
            groupingMaximum: this.getGroupingMaximum(this.props.assemblies),
            filter: '',
            sortby: 'name',
            sortorder: 'asc',
            assemblies: this.getAssemblies(this.props.assemblies, '0', '', 'name', 'asc')
        };

The call to getAssemblies needs to have the '0' changed to "this.getGroupingMaximum(this.props.assemblies)" as well.

Recording this here incase it helps somebody else in the futrue.

Greg

from reportgenerator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.