Blogs

DevExpress Data Blog

This blog features all things having to do with data shaping, layout, and presentation!

July 2011 - Posts

  • Accessing the Report Preview Model in LightSwitch

         

    In this blog post I will explain another small feature of XtraReports for LightSwitch: the ability to access the ReportPreviewModel from code. For example, I will show how you can provide custom editors for report parameters in a LightSwitch application.

    Starting with our next minor release, in addition to the capability of passing parameters from LightSwitch queries to reports, …

    LightSwitch queries and XtraReports parameters

     … we have also added a new CustomizeReportPreviewModel method, which can be specifically used for accessing the ReportPreviewModel

      Accessing Report Preview Model in LightSwitch

    The above code is generated automatically in a ReportPreviewScreen's code behind. You should not rename this method or modify its type and visibility scope (public void).

    Now, let’s use a ComboBoxEdit (which is part of our DevExpress Editors for Silverlight) as a custom parameter editor.

    using System.Collections.Generic;
    using DevExpress.Xpf.Editors;
    using DevExpress.Xpf.Printing;
    // ...
    
    namespace LightSwitchApplication {
        public partial class ReportPreviewScreen {
            public void CustomizeReportPreviewModel(ReportPreviewModel model) {
                model.CustomizeParameterEditors += model_CustomizeParameterEditors;
            }
    
            List<object> categories;
    
            void model_CustomizeParameterEditors(object sender, CustomizeParameterEditorsEventArgs e) {
                if (e.Parameter.Name == "CategoryName") {
                    var editor = new ComboBoxEdit();
                    editor.ItemsSource = categories;
                    editor.IsTextEditable = false;
                    e.Editor = editor;
                    e.BoundDataMember = "EditValue";
                }
            }
    
            partial void ReportPreviewScreen_Activated() {
                this.ReportTypeName = "XtraReport1";
                categories = new List<object>();
                foreach (Category category in new DataWorkspace().NorthWindData.Categories) {
                    categories.Add(category.CategoryName);
                }
            }
        }
    }
    

    Here is the result!

     Creating custom parameter editors with XtraReports for LightSwitch

     Please feel free to leave your comments below. 

  • WPF Reporting Webinar–Making a Drill Through Report

         

    Hey guys! Last week we did a webinar on some of the cool features we have available in WPF in conjunction with reporting. We wanted to post some notes to help you get started with drill-through reporting in WPF as well as provide a recap of the things we discussed in the webinar.

    WPF Reporting Webinar

    The new WPF report preview features we covered at the end of the webinar include:

    The meat of the webinar centered around actually taking advantage of some of the interactive preview events we added in WPF and Silverlight. We used some of these events (the PreviewClick, PreviewDoubleClick, and PreviewMouseMove) to create an interactive drill through Orders/Invoice report. Here is what you can expect:

    1. A brief introduction to MVVM and how to use it in conjunction with reporting
    2. A brief demonstration of our DockLayoutControl to set up a standard layout in WPF
    3. A demonstration of the interaction between the ViewModel class an the View using standard binding to Properties and Commands
    4. The creation of an interactive report!

    The Orders report was simply a report detailing all of the orders in the Northwind database:

    WPF Orders Report

    We used the PreviewMouseMove in conjunction with the report label’s tag to indicate that an element of the report was indeed clickable. Then we used the PreviewClick event to trigger a report change in the WPF Viewer:

    WPFSample2

    In addition to loading the Invoice report, the event also signaled the Orders button to be visible via the binding (without having to do much else).

    Want to play with the code? Jump on over to our support center to download the sample.

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • Filtering Report Data using LightSwitch Query Parameters

         

    In the next minor release (v2011 vol 1.6), XtraReports will provide the capability to filter your report's data on the server-side by utilizing LightSwitch queries. This blog demonstrates this functionality.

    After adding a query to your application…

    Adding LightSwitch Query

    …you can define a parameter to be used in its filtering criterion, …

    LightSwitch queries in XtraReports

    Now all you need to do is bind to the query in the report

    Binding XtraReport to LightSwitch Query

    ... and the rest is taken care of automatically.

    Passing parameters to LightSwitch reports

    Once the application is run, the Parameters panel of the report's Print Preview will be enabled so that you can pass values to the query parameter which then re-creates the report document.

    Passing parameters to XtraReports in LightSwitch

    Please feel free to leave your comments below.

     

  • DevExpress LightSwitch Extensions

         

    Visual Studio LightSwitch 2011

    We are tremendously excited about the fantastic extensions we are releasing for LightSwitch. In conjunction with our reporting offering (more below) we are bundling some of our data editors for FREE as well.

    ReportingLightSwitch Sample Report

    As you have seen in previous blog posts, some of the features include:

    • On Demand Page Loading – makes for snappier reports
    • Native LightSwitch Data Structure Support – make reports from Entities *AND* Queries
    • Our Standard Report Designer – what more can I say?
    • Simple licensing

    We will definitely be adding more blog posts showing the versatility of reporting within LightSwitch!

    Here is what we have done so far:

    Editors

    We have also added some DXEditors to our LightSwitch offering. These are completely free! Here are some of the ones you can look forward to seeing:

    • Masked Text Edit
    • Accounting and Percentage Editors
    • Web Image and Web Link Edit
    • Data Grid Integration

    Licensing

    Licensing (for some) is always a challenging thing to approach. In this case we can describe the whole of it in 3 simple statements:

    1. Reporting for LightSwitch is an additional feature we have added for our existing reporting customers.
    2. If you are not a current customer and want to add reporting into your LightSwitch application the purchase price is $99.99 per developer.
    3. We will *NEVER* charge you runtime royalties fees or distribution costs.

    Our New LightSwitch Page

    Because of all of our new products that we have released, we have released a new page devoted to LightSwitch. You can check it out here:

    http://devexpress.com/LightSwitch

    We are anxious for your thoughts!

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • LightSwitch Reporting - Showing your Reports in a Separate Screen

         
    We have added a great new feature to our reporting offering in an upcoming minor release (v2011 vol 1.6): a custom print preview screen!

    Now, instead of showing a report preview full-screen by calling the PrintPreview.Show() method as before, you can add a specialized screen to your application, …

    LightSwitch Report Preview screen

    … and in the body of its Activated() method call, associate the screen with the required XtraReport instance.
     
    namespace LightSwitchApplication {
        public partial class ReportPreviewScreen {
            partial void ReportPreviewScreen_Activated() {
                // Assign the name of the report, which you want to preview in this screen.
                this.ReportTypeName = "LightSwitchApplication.XtraReport1";
            }
        }
    }

     
    The report will now appear in a separate tab (as opposed to full screen):

    Report Preview for LightSwitch

    In the above screenshot, you may have noticed the new Parameters button being added to the report preview toolbar – a subject of our next blog post.

    As always, if you have any questions and/or comments, please do let us know!
  • How to Install XtraReports for LightSwitch

         
    This blog provides step-by-step instructions on how you can install XtraReports extensions for LightSwitch and start creating reports in your LightSwitch applications from the ground up.

    First, install the Microsoft Visual Studio LightSwitch itself, whose Beta 2 is available at http://www.microsoft.com/visualstudio/en-us/lightswitch. If you are using Visual Studio Professional, this installer will enable LightSwitch extensions for it.

    Visual Studio LightSwitch download

    After this, download the DevExpress Controls and Libraries trial from the DevExpress Client Center.

    DevExpress Installer download

    After you run the installer, on the Product Selection page, check XtraReports for LightSwitch and then click Next.

    XtraReports for LightSwitch Installer

    In order to get full-fledged reporting for LightSwitch, you do not need to select any other product in our installer: XtraReports for LightSwitch is a self contained package.

    When the installation has finished, you are ready to create your first report in LightSwitch. For detailed instructions on LightSwitch reporting with DevExpress XtraReports, see LightSwitch Reporting Preview.

    In case you have any questions or challenges using our products, please feel free to contact our Support Team: we guarantee an answer within 24 hours.

    Please note that Visual Studio LightSwitch is still in beta, which means that until its official release (at the end of July), we plan to improve our reporting extensions. Some aspects of LightSwitch reporting are still subject to change. To stay informed about upcoming XtraReports features for LightSwitch, follow us on our blogs: http://community.devexpress.com/blogs.
  • Silverlight Reporting - Accessing Subreports' Parameters

         

    Here is a brief overview of a small new feature we'll introduce to help simplify use of subreport parameters in Silverlight. 

    In previous versions, accessing client-side subreport parameters when using nested subreports was inconvenient. The ReportPreviewModel provided the Parameters property, access its subreport and then use the Parameters property of the subreport again.

    the previous approach to access a subreport's parameters

     

    This is why we have simplified access to a subreport's parameters. For example, the following code can change the default value for a subreport’s parameter. 

     

    void PreviewModel_RequestDefaultParameterValues(object sender, EventArgs e) {
        PreviewModel.Parameters["subreport1.fromDateParameter"].Value = new DateTime(2002, 11, 30);
        PreviewModel.Parameters["subreport1.toDateParameter"].Value = new DateTime(2002, 12, 31);
    }

    The following image demonstrates the result.

    passing parameter values to subreports with XtraReports for Silverlight

     

    These changes will take effect with our next minor release (v2011 vol 1.6).

     

     

    You can download a sample application that demonstrates this feature here: How to pass parameter values to subreports in Silverlight.

     

     

    Please feel free to share your thoughts and comments. 

  • Towards Code Correctness–A Webinar with Dino Esposito This Friday, July 8th at 10:00AM PST

         

    t_DinoE08aIf any of you have been around the Microsoft world for any period of time then you have heard of the great Dino Esposito. He is a member of the venerable IDesign Team and a prolific author and teacher. Any conference of good repute has him speaking and every other wants him there. I approached him several months ago to do a webinar on any topic(s) of his choice and graciously accepted! If any of you are like me (pre-DX), I rarely had a chance to go to any conference to see the “greats.” As part of our ongoing webinar series DevExpress wants to bring the conference feel right to your computer with great speakers and even greater topics.

    In this installment Dino talks code contracts in conjunction with unit testing in order to drive us towards code correctness. The webinar is Friday, July 8th at 10:00 AM PST. Here is his description:

    “We all agree that writing tests is helpful, recommended and even sexy. However, unless you associate it with some test-driven design methodology, writing tests risks being an end in itself. On one hand you have the classes to test; on the other hand, you have classes that promise to test other classes. And nothing in the middle that guarantees that tests are appropriate and meaningful. An approach that creates the environment for a much more effective refactoring, while not excluding unit testing, is based on software contracts. A software contract defines the terms and conditions for each method in each class. That gives you an optional run time checking mechanism as well as concrete guidance on how to refactor when you have to. Software contracts are not a new concept in software, but only now they have a widespread implementation in .NET. This webinar shows you why you should look seriously at software”

    Don’t miss it! You can register here:

    Towards Code Correctness: Integrating Software Contracts and Unit Testing

    See you there!

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • Filtering Report Data on the Server

         

    I was recently made aware of a great suggestion involving filtering reports on the server side. Lets spend a minute looking into how to do this! Obviously situations will vary, but the general idea should be about the same when using TableAdapters.

    Adding the Query

    The first step is to add a specialized query to the existing table:

    AddQuery

    When adding the new query, you will be prompted with a setup wizard. The key here is the following step:

    Query

    This type of query (with the question mark) will create the appropriate methods that will take in a category id and filter the data appropriately on the server side. Once this has been completed, you should see something like this:

    NewTable

    The last step in the wizard asks for names of the two methods (one that fills a datatable and one that returns one). I chose FillByCategoryID and GetDataByCategoryID.

    Report Parameters

    I created a simple product report based on the Northwind Access Database. Once in the report, head on over to the Parameters section in the field list and add a new CategoryID parameter

    AddParam

    and set the appropriate values:

    ParamSettings

    In this instance, I am defaulting to the value 1. Make sure the parameter is visible! This setting is what dictates whether or not the report preview will add UI to ask for the parameter value. An important point to add here is the RequestParameters property on the report.

    RequestParams

    This important property dictates whether or not the document goes through its creation cycle before parameter values have been submitted. In this instance it should be set to true. In other words we don’t want the report to generate at all unless we have values for the parameters.

    Some Code

    Now to add some logic! There is a report event called ParametersRequestSubmit that is fired when values for the parameters have been set:

    ParametersRequestSubmit

    We will use this event to add the code required to fill our data table:

    FillByCategory

    Notice that our table adapter now has a new method that corresponds to the query we added in the first step. Now for the actual code:

    private void ProductReport_ParametersRequestSubmit(object sender, ParametersRequestEventArgs e)
    {
        if (Parameters["CategoryID"] != null)
            productsTableAdapter.FillByCategoryID(northwind1.Products, (int)Parameters["CategoryID"].Value);
    }

    The Outcome

    Now for the magic! The report will ask for a category ID:

    Params

    and then the report will be generated:

    report

    The code to fire this off:

    private void buttonShow_Click(object sender, EventArgs e)
    {
        ProductReport report = new ProductReport();
        report.ShowPreviewDialog();
    }

    Hope this helps!

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.