Forum Index

No notifications
Notifications

Favorites

No favorites found
General Training Discussion General chat and comment on KnowledgeKube training
Subscribe to post
User avatar
andrew.matthews - (20/09/2016 12:11:02)
RE:Mapping Data Source Grid Image to a Link
Hello, There are two approaches to this, the first is to use JavaScript to manipulate the grid. The second approach involves KnowledgeKube expressions and a little knowledge of HTML. There is a column type for data source grids called Derived Column which allows the results of an expression to be displayed for each row. A useful feature of KnowledgeKube is that any valid HTML in for example the Question Text of a Read Only Question or the result of a Derived Column will get rendered by a web browser. However, please be careful with how this is used as HTML will not render on Enterprise Server Models. If you include the image and link URLs in the data source grid you can use a Derived Column to combine these into a single HTML element using the FormatString function.
FormatString(StringFormat, VariableList);
FormatString allows you to take a number of variables and insert them into placeholders in a string, for example:
FirstName := "John";
LastName := "Smith";
FormatString("{0} {1}", "FirstName,LastName");
This would combine the values of FirstName and LastName into a single string with a space between ("John Smith"). The numbers between the { and } characters are the placeholders for the variables in the list using a zero-based index (the first item in the list is {0}, the second {1} and so on).
FormatString("", "LinkURL,ImageURL");
The expression above will take the two keywords LinkURL and ImageURL (keywords from your data source grid) and insert them into the format string, resulting in an image (ImageURL) that will go a webpage (LinkURL) when it is clicked. The "target=_blank" is optional but will make the link open in a new browser tab. Many Thanks, Andy
RSS Feed