This project has moved and is read-only. For the latest updates, please go here.

Passing Report Parameters in MVC

Dec 7, 2011 at 7:17 PM

Does anyone know how to pass report parameters in like this:


When I add the query string, the route is no longer matched correctly and I get the 404 error.

I have a hack that uses an {id} in the route that I can share, but I am wondering if I am missing something obvious?

Dec 8, 2011 at 6:33 AM

Thanks for catching this! I've fixed this bug in the latest source, going to publish another NuGet package with the fix right now.

Dec 8, 2011 at 6:42 AM

The package has been updated to 1.2.1 please let me know if it fixes it

Dec 10, 2011 at 10:43 PM
Yes, it's fixed.

From: [email removed]
To: [email removed]
Date: Wed, 7 Dec 2011 22:42:13 -0800
Subject: Re: Passing Report Parameters in MVC [doddlereport:282176]

From: mhidinger
The package has been updated to 1.2.1 please let me know if it fixes it
Read the full discussion online.
To add a post to this discussion, reply to this email (
To start a new discussion for this project, email
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at
Dec 23, 2011 at 3:21 PM

Tested today with Dynamic Linq and parameters from JQGrid and it works perfect. Waiting for some more formatting options.

Dec 23, 2011 at 3:43 PM
What kind of formatting options are you looking for?

And would you possibly be up for sending a pull request with them in the code :)

Sent from my Windows Phone

From: farrukhsubhani
Sent: 12/23/2011 10:22 AM
Subject: Re: Passing Report Parameters in MVC [doddlereport:282176]

From: farrukhsubhani

Tested today with Dynamic Linq and parameters from JQGrid and it works perfect. Waiting for some more formatting options.

Feb 7, 2013 at 5:53 AM
Ok its been a long time and i came to this thread to say thanks for all the work so far. Anyone looking to integrate jQgrid and Doodle report. Here is a snippet and technique.
  1. You need to create your report so it can take a request similar to jqGrid.
  2. You can apply filters and other stuff to your query before creating a report.
  3. You can then add buttons/links on top of jqgrid (not in navigation but outside jqgrid)
  4. Click on links to see pdf,xls,xlsx or txt reports.
So the code (using Lib.Web.Mvc nuget package you can get strongly typed helper for jqGrid)
public ReportResult YourReport(JqGridRequest usreq)
            //Getting total records count
            int totalRecords = context.myObjects.Count();
            int page = usreq.PageIndex + 1;
            int pageIndex = usreq.PageIndex;
            int pageSize = usreq.RecordsCount;
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            // Apply filters - you can see how this is done from
                    var query = context.functionalRiskMigrations.AsQueryable()
                    .OrderBy(usreq.SortingName + " " + usreq.SortingOrder)
                    .Skip(pageIndex * pageSize)

             // Create report object
                   var report = new Report(query.ToReportSource());

            // Render hints allow you to pass additional hints to the reports as they are being rendered
            report.RenderHints.BooleanCheckboxes = true;
            report.RenderHints.BooleansAsYesNo = true;
            report.RenderHints.IncludePageNumbers = true;

            // This will generate a Landscape Report. Uncomment or Change Orientation
            report.RenderHints.Orientation = ReportOrientation.Landscape;

            //Header Setup
            report.DataFields["addedBy"].HeaderText = "Created By";
            report.DataFields["dateAdded"].HeaderText = "Created On";

            //Format Setup
            report.DataFields["addedBy"].DataFormatString = "{0}";
            report.DataFields["dateAdded"].DataFormatString = "{0:g}";

            // Advanced customized on a row-by-row basis (Pending)
            report.RenderingRow += report_RenderingRow;

            return new ReportResult(report);

        void report_RenderingRow(object sender, ReportRowEventArgs e)
            if (e.Row.RowType == ReportRowType.DataRow)
                var whenModify = (DateTime)e.Row["dateAdded"];
                if (whenModify < DateTime.Now.AddDays(-5))
                    e.Row.Fields["dateAdded"].DataStyle.Bold = true;
                    e.Row.Fields["dateAdded"].DataStyle.ForeColor = Color.FromArgb(0, 255, 200, 0);
                    e.Row.Fields["addedBy"].DataStyle.Bold = true;
In your view you can then link to this controller (mycontroller) and action (YourReport) as following using Twitter Bootstap icons
<div class="btn-group">
        <a class="btn report" href="#" data-ext="html" data-report="@Url.Action("YourReport","mycontroller")"><i class="icon-black icon-print"></i> Print</a>
        <a class="btn report" href="#" data-ext="xls" data-report="@Url.Action("YourReport","mycontroller")"><i class="icon-black icon-th-list"></i> CSV</a>
        <a class="btn report" href="#" data-ext="xlsx" data-report="@Url.Action("YourReport","mycontroller")"><i class="icon-blue icon-th-list"></i> Excel</a>
        <a class="btn report" href="#" data-ext="txt" data-report="@Url.Action("YourReport","mycontroller")"><i class="icon-black icon-circle-arrow-down"></i> Tab Delimited</a>
I am using data-ext and data-report (url) to create dynamic urls for the report with all parameters picked up from postData of jqGrid. So you can see the url for each is set to # but actual report base url is stored in data-report. I dont need to store it for all a tags if its same but for simplicity of following javascript and making it easy to control report urls i am using this technique.

Now the javascript magic will populate the url so you need to call the following function on yoour jqgrid complete method. If you are not aware how to call it just create this js first and i will show at the end how to add that method in lib.web.mvc as well.
function setupReportbuttons() {
            myUrl = "";
            var postData = jQuery("#@grid.Id").jqGrid('getGridParam', 'postData'); //again @grid.Id is being used from Lib.web.Mvc
            jQuery.each(postData, function (key, value) {
                myUrl += "&" + key + "=" + encodeURIComponent(value);
            jQuery('.report').each(function () {
                var ReportUrl = $(this).attr("data-report");
                var ReportExt = $(this).attr("data-ext");
                var newReportUrl = ReportUrl + "."+ReportExt+"?rep=true" + myUrl;
                $(this).attr("href", newReportUrl);
            // I am setting ?rep=true just for my own sake and making life easy instead of testing if there are already any parameters or not and adding ? or & so and so. You can improve this function a lot.
Now as i said you need to call this from gridComplete function so if this is the only function to call on comlete then you can do so by setting it in helper as
    other properties here
    width: 960,
    shrinkToFit: false,
    gridComplete: "setupReportbuttons",
    more properties here
If you have some other function setup on complete just call setupReportbuttons(); within that and you are good to go.