Posted 19 March 2018, 4:45 pm EST
Can a FlexReport be bound to a viewmodel in uwp?
Forums Home / ComponentOne / UWP Edition
Posted by: fsl on 19 March 2018, 4:45 pm EST
Posted 19 March 2018, 4:45 pm EST
Can a FlexReport be bound to a viewmodel in uwp?
Posted 20 March 2018, 11:05 pm EST
Hello,
We have a blog demonstrating how to use FlexReport in a MVVM application, in WPF edition. And since the implementation and approach remains same with UWP, we suggest you to refer it once: Using the WPF Report Viewer in an MVVM Application | ComponentOne
In any case, if you still need any help or get stuck, please let me know. I will be happy to help you.
Thanks, Ruchir Agarwal
Posted 11 April 2018, 1:25 am EST
Thank you for your reply. The blog shows how to bind the report viewer to the ViewModel. We were wondering if the report designer can access the ViewModel to create the actual report.
Posted 11 April 2018, 3:10 pm EST
Hi, I could not understand your requirement exactly. If you are talking about to use a list of a model object like List as C1FlexReport’s data source. Then try to implement the IC1FlexReportExternalRecordset in your custom class and return the data to data source as per your requirement. You can see the link below: http://help.grapecity.com/componentone/NetHelp/FlexReportUWP/webframe.html#C1.UWP.FlexReport~C1.Xaml.FlexReport.IC1FlexReportExternalRecordset.html
A similar implementation sample for winforms installed at: …\Documents\ComponentOne Samples\WinForms\C1FlexReport\CS\ExternalDataSource
Thanks, Singh
Posted 14 May 2018, 7:09 pm EST
My question was unclear, my apologies. Can the FlexReportDesigner be used with UWP and access data in a viewmodel?
Posted 15 May 2018, 6:28 pm EST
Hi, This is not possible to use FlexReportDesigner in UWP application.
Thanks, Singh
Posted 15 May 2018, 7:14 pm EST
Thank you Singh. How are UWP reports designed using your tools? Our team has a designer who is not a programmer.
Posted 16 May 2018, 5:29 pm EST
Hi,
One can design the reports using FlexReportDesigner and then, these reports can be viewed in the FlexViewer for UWP. Please refer the following documentation links for more information on this: Working with FlexReportDesigner:
Creating Report Definition: Step 1 of 4: Creating a Report Definition
Viewing Reports: UWP Edition Documentation
Please let me know if you have any additional questions on this.
Thanks, Pragati
Posted 21 May 2018, 10:06 pm EST
Thank you Pragati. I’ve run ComponentOneUltimateInstallerv20181.1.3 and generated a license key here The benefits of your GrapeCity account... and added the license key to our app according to the instructions here Generate an app key | ComponentOne.
The line C1.UWP.LicenseManager.Key = has a squiggly under C1 and the error C1 does not exist in the current context. What have I missed?
Also if I may. We are currently trying to link the C1FlexReportDesigner.4 to a C# data class in a UWP project, do you have any docs on how to do this. Many thanks in advance
Posted 23 May 2018, 12:37 am EST
Hi,
[quote]The line C1.UWP.LicenseManager.Key = has a squiggly under C1 and the error C1 does not exist in the current context. What have I missed? [/quote]
Please check your project contains the reference of C1.UWP assembly. If not then add it using the below steps:
[quote]Also if I may. We are currently trying to link the C1FlexReportDesigner.4 to a C# data class in a UWP project, do you have any docs on how to do this. Many thanks in advance [/quote]
This is not possible to link C1FlexReportDesigner.4 to a C# data class in a UWP project or vise-versa. This can only be achieved using winforms. In UWP, I suggest you to use List in code behind as report data source. Please refer the attached application where FlexReport is bound to a list of objects. Hope that helps.
Thanks,
Posted 23 May 2018, 11:02 am EST
Thank you for that sonu.singh. As I undersand from your answer we must use a viewer in UWP but the designer must be from another project type.
We also write Xamarin and Asp.Net Core applications. Can we use the report designer in a Xamarin or Asp.Net Core project to design a report and view that in UWP using the viewer?
Posted 23 May 2018, 3:40 pm EST
Hi,
Please note, This can only be achieved with winforms.
Hope, it clarifies for you.
Thanks, Singh
Posted 10 June 2018, 10:05 pm EST
Please bear with me if I appear obtuse. Here Bind a FlexReport to a viewmodel in UWP | UWP Edition | ComponentOne Studio | GrapeCity Forums we are told how to bind the report viewer to the ViewModel.
Then here
we are told This is not possible to link C1FlexReportDesigner.4 to a C# data class in a UWP project or vise-versa. This can only be achieved using winforms.
Does that mean we can use the GrapeCity report designer for Winforms to create a report that gets its data from a UWP viewmodel and that report can then be viewed in a UWP application?
Posted 11 June 2018, 8:32 pm EST
Yes, exactly this is what was meant. Please let me know if you have any confusion on this.
Thanks.
Posted 17 June 2018, 2:15 am EST
Thank you pragati. sonu.singh told us we can find an implementation sample for winforms installed at: …\Documents\ComponentOne Samples\WinForms\C1FlexReport\CS\ExternalDataSource
Is that an internal link? Are you able to give us the full URL for the sample please?
Are there instructions anywhere that step us through using the GrapeCity report designer for Winforms to connect to a UWP viewmodel?
Posted 17 June 2018, 9:31 pm EST
Hi,
You can download the sample from the link below:
Alternatively, you can find it in your [UserDocuments] folder as mentioned by Sonu.
>>Are there instructions anywhere that step us through using the GrapeCity report designer for Winforms to connect to a UWP viewmodel? There are no instructions available as such. However, you can create a report using the designer as described in the documentation: http://help.grapecity.com/componentone/NetHelp/FlexReport/webframe.html#WorkingwithFlexReportDesigner.html
and, then use that report in your UWP application, as mentioned above.
~Pragati
Posted 18 June 2018, 12:24 am EST - Updated 30 September 2022, 12:08 am EST
Hi Pragati
Thank you for you reply.
I’ve downloaded the example and followed the instructions provided with the download.
When I open the ExtRecordset.dll from the designer I get the error attached.
Please advise.
Many thanks.
Posted 19 June 2018, 4:08 pm EST
Hi, I escalated this to developer team. Will let you know as soon as there is any information from them.
[TFS ID: 328113 for internal use only]
Thanks, Singh
Posted 24 January 2020, 1:44 pm EST
We are now trialing the new FlexReport designer for UWP. Please tell me now how do we connect the FlexReport designer to a UWP viewmodel in order to create the report definition?
Posted 27 January 2020, 11:31 pm EST
Hello,
As per mentioned above this is not possible.
~Ruchir
Posted 28 January 2020, 12:25 am EST - Updated 30 September 2022, 12:07 am EST
Hello Ruchir,
There is a new feature “Data binding using External Objects”.
https://www.grapecity.com/componentone/docs/uwp/online-flexreport/DataBindingusingExternalObjects.html
Are you saying that while it is possible to bind the report to objects, there is no way for the designer to connect to the object so the report can be built?
In the C1FlexReportDesigner connection wizard there is the option for the Data Provider: “Connection to object in external assembly”. This appears to indicate that it is possible to connect the designer to external objects, but I cannot find any docs with information on this.
Many thanks in advance.
Posted 30 January 2020, 11:41 pm EST
Hi,
Before confirming it to you, I have a concern that I am currently discussing with the developer [ID: 419159]. I will update back to you with confirmation as soon as I receive the information.
Thanks for the patience,
Regards, Ruchir
Posted 7 February 2020, 7:10 am EST
Any further news on this Ruchir?
Posted 9 February 2020, 8:24 pm EST
Hi,
Currently, there are no updates. So, I have requested the developer for a status update. I will get back to you once we have some information.
Thanks, Ruchir
Posted 25 February 2020, 9:39 pm EST
Hi Ruchir. It’s now been almost 4 weeks since you referred this to the developer. Are you able to escalate this issue so we get a response?
Posted 27 February 2020, 10:57 pm EST
Hello,
Yes, I have already escalated the issue to the development team. Understanding that the issue is critical for you, so I have now mailed the developer asking for an ETA. I will keep you updated with the information we receive from the developers.
Thanks, Ruchir
Posted 26 March 2020, 8:51 am EST
Two months now since you escalated this issue Ruchir, but nothing. Give me a reason to wait.
Posted 26 March 2020, 1:44 pm EST
Hello,
To meet your requirement, you need to make your ViewModel implement the IC1FlexReportRecordset and IC1FlexReportExternalRecordset interfaces. A demo application has been prepared and attached here for reference.
Thanks, Ruchir Library_MVVM.zip
Posted 27 March 2020, 11:38 am EST
Thank you for the example Ruchir. The example deals with a simple list of customers. The example reads the properties of customers and copies them into private List _props;
But viewmodels are generally more complex than that. For example a statement run would be a collection of statements. Each statement would include a collection of orders. How do we deal with that? A minimal example public class StatementViewModel { public List Statements { get; set; } public string CustomerId { get; set; } public string CustomerName { get; set; } } public class Statement { public string CustomerId { get; set; } public string AddressLabel { get; set; } public List Orders { get; set; } } public class Order { public string CustomerId { get; set; } public string OrderId { get; set; } public int OrderNr { get; set; } } As you see a statement run produces a list of statements. Each statement includes a list of Orders
How do we expose the properties through List when some of those properties are lists and we must also expose the properties of nested list items?
Posted 30 March 2020, 9:06 pm EST
Hello,
Thank you for the question, I am further investigating on how to implement such a requirement. I will reply with the information soon.
~Ruchir
Posted 10 April 2020, 5:16 pm EST
Hi,
It is possible. To do this:
Thanks, Ruchir Library_MVVM_new.zip
Posted 12 April 2020, 9:50 am EST
My apologies Ruchir, perhaps my question wasn’t clear. You sent a link to this same example in your earlier reply. The example shows how the developer must make explicit to FlexReport the properties of the viewmodel by copying the properties of the customer class into a list, like this
public CustomerViewModel()
{
_repository = new CustomerRepo();
_customers = _repository.GetCustomers();
var props = typeof(Customer).GetProperties();
_props = new List<PropertyInfo>();
foreach (var prop in props)
if (prop.CanRead)
_props.Add(prop);
WireCommands();
}
This is easy to understand where the viewmodel is flat. However where the viewmodel includes nested types, how are those types to be represented? In the statement run example I mentioned. How are orders represented in this list of types?
Posted 13 April 2020, 7:49 am EST
My apologies Ruchir. Let me look into it and get back to you.
Posted 14 April 2020, 2:01 pm EST
Thank you Ruchir that seems to work nicely. I am able to set the report data source to the StatementViewModel and the properties are visible as I hover over in Visual Studio.
Thank you for your patient assistance.