Hi,
I’m trying to print a Dashboard with plots to PDF.
This is basically the Dashboard example from the docs with a couple of enhancements, plus trying to print the results to PDF.
First, what I think I got right (of course, subject to be corrected)
- What you will print is not the page the user is seeing, but another Form that receives the values that the user has entered in the interactive form
- Then you call a server function render_form to which you pass the values entered by the user, and the name of the “printing form”.
- What will happen is that the server function will call the render_form which is basically the same as open_form, so you rebuild the original Form with a perhaps a more printable layout.
So far so good. I’ve tried this with simple components like dropdown lists and labels and it works.
Now, the problem:
In the application, the user creates a bunch of charts that display inside a grid panel. The charts are created as Timeplot components (which is another Form/Class in the application), and added to the gridpanel.
So, following the same logic I pass the gridpanel to the server function so it can pass it to the “printing form” on the render_form call.
And there is when I get
SerializationError: Cannot pass TimePlot object to a server function: arguments [2][1][“$_components”][0][0]
I understand that there are limitations in the type of object you can pass from client to server and vice-versa.
So it seems clear that I cannot pass (or don’t know how to pass) the gridpanel to the server.
I’ve read many posts with similar, but not equal problems, and I was a bit overwhelmed because the OO is still a bit elusive to me.
I’ve also thought about defining the Timeplot class as Portable
But for that I would need the Form to be a Module instead.
And, I’m not sure that this would solve the problem, as in another post Meredith says that despite the Portable definition, the limitations on the kind of object you can pass remains the same in terms of what kind of things you can pass.
At this point I’m a bit lost on how to procede.
Any direction I look, looks a bit confusing in that, first, for printing this I have to rebuild the Form, and now with this more complex type, I might need to pass not only the input of the main form (Dashboard) with the plots created by the user into the gridpanel, but also the input of the Timeplot form, and then write a whole new logic in the “printing form” to simulate the user input and the plot generation, and only then be able to print them.
This doesn’t seem right (too much work for what it is advertised as a very simple solution), so probably it is not, and I’m looking at it the wrong way.
So, I would really appreciate a pointer in the right direction!!
I attach the application so you can see it firsthand and match it with the explanation (in case I haven’t been clear enough)
Thank you very much!!