Silverlight4: devexpress report

Source: Internet
Author: User

I don't know what a good solution is available for report reports in silvelright, except for the Silverlight report controls developed by companies such as devexpress and telerik on the 3rd side. I did not find a decent open-source solution in Google's crazy search. In comparison, select the devexpress report control.

The following content uses devexpress report to complete a report:

There are two methods

1) The report and Silverlight app are in two different windows Windows.

2) reports are embedded in the Silverlight page

Either way depends on the specific requirements.

First, add report. SVC to the Silverlight host web:

/// <Summary>
/// Ireportservice
/// </Summary>
[Servicecontract]
Public interfaceIreportservice: Devexpress. xtrareports. Service. ireportservice {
[Operationcontract]
Entid getreportsbyname (string reportname );
}

/// <Summary>
/// Reportservice
/// </Summary>
[Aspnetcompatibilityrequirements (requirementsmode = aspnetcompatibilityrequirementsmode. Allowed)]
Public classReportservice: Devexpress. xtrareports. Service. reportservice, ireportservice {
Public reportservice (){
}

Const string filepath = "~ /Reports ";
Public byte [] getreportfile (string path)
{
Return file. readallbytes (PATH );
}

Private Static string getabsulotepath (string path)
{
Return "\" + path;
}
Public entid getreportsbyname (string reportname)
{
// Xtrareport report = new xtrareport ();
String Path = httpcontext. Current. server. mappath (filepath + "//" + reportname + ". repx ");
Byte [] bytes = getreportfile (PATH );
Xtrareport report = xtrareport. fromstream (New memorystream (bytes), true );
// Report. datasource = getdata ();
Entid Doc = startbuild (report );
Return Doc;

}
}

Page in Silverlight project: XAML

<Grid X: Name = "layoutroot">
<Stackpanel orientation = "vertical">
<Button content = "button" width = "50" Height = "20" Click = "button_click"> </button>
<My: documentpreview name = "documentpreview1"/>
</Stackpanel>

</GRID>

Place a documentpreview. When a button is clicked, the report is rendered using documentpreview, mainpage. CS

Private void button_click (Object sender, routedeventargs E)
{
Reportservice. reportserviceclient client = new reportserviceclient ();
Client. getreportsbynamecompleted + = new eventhandler <getreportsbynamecompletedeventargs> (client_getreportsbynamecompleted );
Client. getreportsbynameasync ("xtrareport1 ");

}

Void client_getreportsbynamecompleted (Object sender, getreportsbynamecompletedeventargs E)
{
Reportpreviewmodel previewmodel = new reportpreviewmodel (serviceuri. absoluteuri );
Previewmodel.Processdocument(E. Result );
Documentpreview1.model = previewmodel;
// Throw new notimplementedexception ();
}

Const string relativeserviceurl = "/reportservice. SVC ";
Static URI serviceabsoluteuri;
Internal static URI serviceuri
{
Get
{
If (serviceabsoluteuri = NULL)
Serviceabsoluteuri = new uri (application. Current. Host. source, "..." + relativeserviceurl );
Return serviceabsoluteuri;
}
}

Note that servicereference. clientconfig:

<Endpoint address = "http: // localhost: 53609/reportservice. SVC % 22
Binding = "basichttpbinding" bindingconfiguration = "basichttpbinding_ireportservice"
Contract = "reportservice. ireportservice" name = "basichttpbinding_ireportservice"/>

Contract is reportservice. ireportservice

This is a simple devexpress report.

Environment: Visual Studio 2010, silverlight4 devexpress v10.1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.