Template on the fly



  • We are working on a POC wherein the client picks and chooses what sections they require in the report. Does jsreport have such features using which one could generate a jsreport template on the fly and send that to the jsreport server to consume and create the report through a asp.net web forms application.


  • administrators

    hi! there is no such feature in jsreport by default, but it can be created using the primitives that jsreport already provides (for example, jsreport accepts dynamic templates).. try to look deep in the docs and you will see that it is possible, it just depends on your requeriments



  • Is there a asp.net web forms sample application that I could refer to ?



  • I received the following exception -
    e.Message
    "One or more errors occurred."

    e.StackTrace
    " at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n
    at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)\r\n at System.Threading.Tasks.Task1.get_Result()\r\n
    at jsreport.Embedded.EmbeddedReportingServer.<>c__DisplayClass64_0.<StopAsync>b__2()
    in D:\somepath\jsreport\EmbeddedReportingServer.cs:line 172

    System.InvalidOperationException: 'An attempt was made to transition a task to a final state when it had already completed.'



  • Hi, I have the same requirement. I would like to customize my reports by selecting fields to report on.
    As it supports handlebars, I Guess it would be matter of configure the template .... something line the conditional example below .. right?
    https://jsreport.net/learn/handlebars


  • administrators

    @Labretto in order to help you with that error, can you setup a github repository with the code that you are trying and share it here? maybe it is just something configured wrong, i'm not a C# expert but the repository can help me or @jan_blaha to see the problem.



  • @ollivera2000 I think it could be the one of the ways to accomplish our customization. The customization I'm looking to build is something as below --

    Section A - Metadata about a school
    Section B - data table about past programs
    Section C - data table about programs running currently
    Section D - data table about future programs
    Section E - Progress so far
    Section F - Feedback
    Section G - Roadmap
    Section H - ...
    etc..

    User when requesting for a report would pick from these sections (any combination - say A,B,C,D & H). Now within these sections, we have data tables which may have many data fields ( here, we want to allow them to choose which data fields to show in the report under appropriate sections too), thus providing flexibility, yet retaining a robust reporting feature ;)

    Any ideas on how to go about it, are much appreciated :)



  • @bjrmatos yes, I too sense that it could be some configurations done incorrectly. I will share the repo here, once I have it uploaded.
    Thank you. :)





  • You have full power with templating engine like handlebars to achieve your required layout. It is only about learning a bit of handlebars and do some coding.

    Your example repository needs to differently handle async task in void method. It is the same as handling async task in the console Main.
    https://stackoverflow.com/a/24601591/1660996

    More precisely change this

    protected void Button1_Click(object sender, EventArgs e)
    {
                Task.Run(GenerateJsReportAsync).GetAwaiter().GetResult();            
    }
    

    You could also take a look on the preview of the next jsreport .NET sdk release. It could be easier for you attach jsreport into web forms app using jsreport.Local package then with the jsreport.Embedded.
    https://jsreport.net/learn/dotnet-v2
    https://jsreport.net/learn/dotnet-local



  • @jan_blaha : Thank you. However I ran into the below after making the suggested change.

    An exception of type 'System.AggregateException' occurred in mscorlib.dll but was not handled in user code
    Additional information: One or more errors occurred.

    On Preview packages, I installed jsreport.Local and jsreport.Binary into the project.
    On this line of code
    var rs = new LocalReporting().UseBinary(JsReportBinary.GetBinary()).AsUtility().Create();
    I get

    LocalReporting() - the type or namespace name 'LocalReporting' could not be found.

    0_1502191040943_upload-663c061d-8dc2-46b8-b0bf-7eb2a9b02f90

    below are the usings
    0_1502191292512_upload-7dc7bdcb-e8bd-4c4f-b89e-704556ce585e

    Jsreport.Local doesn't have the def for LocalReporting()
    0_1502191426570_upload-3b21cefc-ac73-41d4-9950-2feeb130b878



  • You didn't install preview package of the jsreport.Local.





  • Oops! my bad, I hadn't check marked to include pre-release versions when I was searching for it in NPM. Thank you for the quick reply. I'll play around with it a bit and get back.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.