There are a few different ways to impart style into K2 SmartForms. Perhaps the most straightforward way is by using the controls in Designer. Apart from the selection of a style sheet, these controls allow for limited manipulation of style elements on objects placed within a SmartForm. For greater style control, one must consult the style sheets that comprise the themes.
There is, however, another way: One can create a style sheet and implement it directly on a specific SmartForm. The method is hackish and not entirely comfortable architecturally, but it can be done.
This document will walk you through the method used for this “style sheet injection,” and how to deploy the style sheets to other servers.
The K2 SmartForms Picture Control is comprised of:
- The SmartForms Picture control
- A table in the K2 database
- A .NET Generic Handler
Let’s talk about each of these.
Now that we have successfully implemented the Set Language control on a form, and figured out a means of passing the selected language to a subform, it’s time to explore how well the Set Language control performs in translating text on an editable view (a datagrid).
In the second post of this series I showed how you could use XML functions to return your recordset from the database as HTML
row and cell elements (“Make the Database Return Your Recordset as an HTML Table — Using XML”, 8/6/2016). We did this by naming the XML elements after the appropriate HTML elements.
If we stopped at this point, we could create a SmartObject that returns our string of HTML
data to the caller. For example, we can already have the HTML for the rest of the report elsewhere, and this SmartObject simply “plugs in” the data to be displayed. This could be as easy as concatenating strings (say, an HTML report header, the HTML
output from the SmartObject, and an HTML report footer) in a Data Event.
We can go further. By using XSL Transform, we should be able to have the database return our entire HTML report — not just the table.
I emphasized in my previous post the mechanism through which SmartObject data may be accessed within K2 Server Events. The specific example I gave was the case of a reporting feature for which I had been “awarded” responsibility (“Access Your Workflow SmartObjects Through Server Events”, 7/30/2016).
The feature was comprised of a K2 workflow process consisting of a server event that generates the report in HTML, an event that generates a PDF, and and event that persists the PDF in a document management system. As detailed in the previous post, the server event called SmartObjects to retrieve the data for the report, then used a
StringBuilder object to create the HTML through a series of
for loops before returning the completed HTML string to a process-level data field in the workflow process.
I began to wonder if perhaps the database engine could handle this transformation more efficiently, so I started digging into the stored procedures that support the report.