On 01/08/2015 03:15 AM, Bryn Jeffries wrote:
I have a custom groovy script at DemoSpace.StudiesJSON that generates JSON of the form: { "totalrows": 5, "matchingtags": {}, "tags" : [], "offset": 1, "reqNo": 0, "returnedrows": 1, "rows": [{"doc_viewable":true,"study_id":3,"study_name":"My Study","description":"A test study"}] }
This is then called from a LiveTable macro as {{velocity}} #set($columns = ["study_name", "description", "study_id"]) #set($options = { "resultPage":"DemoSpace.StudiesJSON" }) #set($columnsProperties = { "study_name" : { "type" : "text", "displayName": "Study Name", "filterable": false }, "description" : { "type" : "text", "displayName": "Description", "filterable": false }, "study_id" : { "type" : "text", "displayName": "Study ID", "filterable": false } }) #livetable("studyTable" $columns $columnsProperties $options) {{/velocity}}
What I'd really like is to put links into each row, for instance replacing each entry in the first ("Study Name") column with a link of the form [[${study_name}>>StudyDetails?study_id=${study_id}]]. Is there a way to do this? I've tried generating a link in the JSON but the query strings seem to get corrupted and the link is lost in any case within the actual LiveTable.
I think you can do the following here: - change the JSON script generating the results so that "study_name" contains the HTML you want, like:
"rows": [{"doc_viewable":true,"study_id":3,"study_name":"<a href=\"/xwiki/bin/view/StudySpace/StudyDetails?study_id=3\">My Study</a>","description":"A test study"}]
- then set the columnsProperty for study_name to html:
#set($columnsProperties = { "study_name" : { "type" : "html", ...
For a list of accepted options see here: http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro#HParame... Alternatively you could add your own "LiveTableRow renderer" in JavaScript, as explained in the "All Attachments" example on the same page: http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro#HAllAtt... However this is a "all or nothing" solution - you will need to render all columns in the JavaScript, not only the ones you want to customize. I would only use this solution if the first option is not sufficient for some reason. Cheers Clemens
Thanks,
Bryn _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users