I am using Silverlight 4.0. I already have my object that need to show on the report . Can I use client side rendering and display my report without hitting the server side?
I have attached a sampe project . Can you check my sample project and let me know what is the problem is? I am getting the below exceptions
at Infragistics.Controls.Reports.ProcessingSessionStateMachine.CreateProcessor(IRenderingEngineFactory renderingEngineFactory) at Infragistics.Controls.Reports.ViewerStateMachine.Render(Boolean firstRender, IDictionary`2 selectedParameterValues)
I would appreciate if someone can quickly answer my question.
Hi,
Yes that is something you definitely can do with NetAdvantage Reporting.
I take a look at your solution and the problem is in the data passed to the XamReportViewer in the Load event. When an object data source is defined two things are been specified: the structure of the data and how to get that data. In the attached solution the report’s data source is a list of Employees and the data is obtained by instantiating the class EmployeeList and querying the property ListEmployee.
At runtime, when a data source is bound using ClientRenderSettings.DataSources you are the responsible of getting the data. The ItemsSource property expects just the raw data, i.e. a list of employees. In your sample you are setting an instance of class EmployeeList as data source.
So in the load method you should do:
Employee emp = new Employee();
emp.Id = 10;
emp.Name = "Jack";
emp.Age = 90;
emp.Address = "NY";
var rawData = new List<Employee>();
rawData.Add(emp);
ClientRenderSettings renderSettings = new ClientRenderSettings
{
DefinitionUri = "TestAppReporting.Report1.igr, TestAppReporting"
};
renderSettings.DataSources.Add(new Infragistics.Controls.Reports.DataSource
TargetDataSource = "Employee",
ItemsSource = rawData
});
xamReportViewer1.RenderSettings = renderSettings;
That will fix your problem.
Note 1: You can remove the ClientRenderSettings specified in the XAML since you are setting in the load event.
Note 2: Once you do those changes in the Load handler you can also change the implementation of property ListEmployee to something like this:
public List<Employee> ListEmployee
get
return new List<Employee>
new Employee() { Id = 1, Name = "E1", Age = 20, Address = "New York" },
new Employee() { Id = 2, Name = "E2", Age = 20, Address = "Boston" },
new Employee() { Id = 3, Name = "E3", Age = 20, Address = "Miami" },
new Employee() { Id = 4, Name = "E4", Age = 20, Address = "Chicago" },
}
By doing so, you will have sample data in your preview. Be sure to rebuild the SL app before going to preview.
Thanks,
Leo
Thanks, that worked for me. If my Employee object contains a List of Address, how can I display that in the report? Any suggestion?
I used a table, but that didn't help.
; }
Currently the only way to display hierarchies inside the report is using group by. In your scenario you have Employee->*Address. Instead of defining the data source at the Employee level you will have to define it at the Address level and the group each address by Employee. This implies that you will need a way to navigate from Address to Employee (e.g. like a Parent property). The group could be defined over =Fields.Parent.Id for example. Those groups could be defined at the report level or in the table (in the documentation you will find several samples of how to do grouping).
At the XamReportViewer side, if you want to bind the report’s data source to your data and you have a collection of Employees you could generate the list of all Addresses for those employees using something like ListEmployee.SelectMany(e => e.Addresses).
Hope it helps.