LiveTable JSON example

livetable
json

#1

Hi!

I’m trying to fill out Livetable based on JSON data.
The property Custom Dispaly contains the following script:

{{velocity}}
#set($columns = ["first_name", "last_name", "editor"])
#set($columnsProperties = {
   "first_name" : { "type" : "text" , "size" : 20, "link" : "view"},
   "last_name" : { "type" : "text" , "size" : 20, "link" : "view"},
   "editor" : { "type" : "list", "class": "XWiki.XWikiUsers"}
})
#set($options = {
  "resultPage":"Test.TestJSON",
  "translationPrefix" : "",
  "rowCount": 10
})
#livetable("organization_directory" $columns $columnsProperties $options)
{{/velocity}}

TestJSON page located at Test space and contains the script:

{{include reference="XWiki.LiveTableResultsMacros" /}}

{{velocity wiki="false"}}
#gridresultwithfilter("XWiki.XWikiUsers" $request.collist.split(",") "" " and doc.name<>'OrganizationSheet' and doc.name<>'OrganizationTemplate'")
{{/velocity}}

When I open the page, I only see the filled-in list of the filter in the editor field:
%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%BD%D1%8F

How do I get a list of users?

Thanks for the help.


#2

:thinking:


#3

What would I like to do:

  1. Generate a dataset for LiveTable based on a complex HQL query for multiple classes.
  2. Display data in LiveTable.

I can write queries and build tables based on classes:
#set ($ options = {
‘className’: ‘Space.Class’
But can not combine 1 and 2.

I will be grateful for a simple step-by-step example.

Thank you for your attention.


#4

Based on https://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro

  1. %D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%BD%D1%8F
  2. %D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%BD%D1%8F
  3. %D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%BD%D1%8F
  4. %D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%BD%D1%8F
  5. %D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%BD%D1%8F

Where is mistake?

Thanks.


#5

hi, is your Organization.Code.OrganizationClass page a terminal page? If not you need to suffix it with .WebHome.


#6

I think, yes:
%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%BD%D1%8F


#7

What about Organization.ListOrganizationJSON? (is it terminal too?)


#8

Bingo!!! :slight_smile:
Changed it to “Terminated” and see expected list!


#9

Please, also update documentation.
Once again, a huge thank you :sunny: )


#10

I could do that but it would be even more awesome if you could contribute to the doc! :slight_smile: It’s a wiki, you just need to register and edit away! Thx


#11

Ok, done :wink:


#12

Thanks @Rostyslav_Fitsyk. Actually I’ve modified it a bit to move it upwards since this comments is valid for all examples. See https://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro?viewer=changes&rev1=103.1&rev2=104.2


#13

:+1: