[xwiki-users] Using custom JSON in a livetable
Hello! I need help for livetable with custom json page. I did it all, but - no any visual results (rows with data) in a livetable. Maybe I wrote something wrong. For the easy example, I only trying to add column 'no' with row number. ============================================= Content of custom JSON page (etvcPlanningsCode.wJSON): ============================================= {{include document="XWiki.LiveTableResultsMacros" /}} {{velocity}} #if("$!{request.xpage}" == 'plain') $response.setContentType('application/json') #end #set($map = {}) #gridresult_buildJSON("$!etvcPlanningsCode.wClass" $request.collist.split(',') $map) #foreach($row in $map.get('rows')) #set($discard = $row.put('no', "$foreach.count")) #end $json = $jsontool.serialize($map) {{/velocity}} ===================== This content give me result: ===================== $json = {"reqNo":null,"matchingtags":{},"tags":[],"totalrows":539,"returnedrows":15,"offset":1,"rows":[{"doc_viewable":true,"doc_name":"t4pTable","doc_fullName":"xwiki:etvcPlanningsCode.t4pTable","doc_space":"etvcPlanningsCode","doc_url":"/xwiki/bin/view/etvcPlanningsCode/t4pTable","doc_space_url":"/xwiki/bin/view/etvcPlanningsCode/WebHome","doc_hasadmin":true,"doc_hasedit":true,"doc_hasdelete":true,"doc_edit_url":"/xwiki/bin/edit/etvcPlanningsCode/t4pTable","doc_copy_url":"/xwiki/bin/view/etvcPlanningsCode/t4pTable?xpage=copy","doc_delete_url":"/xwiki/bin/delete/etvcPlanningsCode/t4pTable","doc_rename_url":"/xwiki/bin/view/etvcPlanningsCode/t4pTable?xpage=rename&step=1","doc_rights_url":"/xwiki/bin/edit/etvcPlanningsCode/t4pTable?editor=rights","doc_author_url":"/xwiki/bin/view/XWiki/Admin","doc_date":"14.10.2012","doc_title":"t4p Table","doc_author":"Administrator","doc_creationDate":"04.12.2011","doc_creator":"Administrator","no":"1"}, ... ============== My livetable code: ============== {{velocity}} #set($columns = [ "no" , "wIndex" , "wAlias" , "wName" , "wTeam" , "wActive" , "doc.date" , "_actions" ]) #set($columnsProperties = { "no" : { "type" : "text", "size" : 10, "filterable" : true, "sortable": true }, "wIndex" : { "type" : "text", "size" : 10, "filterable" : true, "sortable": true }, "wAlias" : { "type" : "text", "link" : "view", "size" : 10, "filterable" : true, "sortable": true }, "wName" : { "type" : "text", "link" : "view", "size" : 10, "filterable" : true, "sortable": true }, "wTeam" : { "type" : "text", "size" : 10, "filterable" : true, "sortable": true }, "wActive" : { "type" : "text", "size" : 10, "filterable" : true, "sortable": true }, "doc.date" : { "type" : "text", "size" : "10", "filterable" : true, "sortable": true }, "_actions" : { 'actions' : ['edit', 'delete'] } }) #set($options = { "resultPage" : "etvcPlanningsCode.wJSON", "translationPrefix" : "w2.livetable.", "rowCount": 15, "maxPages" : 10, "selectedColumn" : "wIndex", "defaultOrder" : "asc" }) #livetable("w2" $columns $columnsProperties $options) -- Thanks beforehand! Eugen Colesnicov -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-custom-JSON-in-a-livetable-tp7582208... Sent from the XWiki- Users mailing list archive at Nabble.com.
I found one issue on custom JSON page. My last variant: ============================================= Content of custom JSON page (etvcPlanningsCode.wJSON): ============================================= {{include document="XWiki.LiveTableResultsMacros" /}} {{velocity}} #if("$!{request.xpage}" == 'plain') $response.setContentType('application/json') #end #set($map = {}) #gridresult_buildJSON("$!etvcPlanningsCode.wClass" $request.collist.split(',') $map) #foreach($row in $map.get('rows')) #set($discard = $row.put('no', "$foreach.count")) #end $json = $jsontool.serialize($map) {{/velocity}} Also I checked JSON result with http://jsonlint.com/ - I got "Valid JSON" ... But unfortunatly - no any results in a livetable ... Can somebody can help me? -- Thanks beforehand! Eugen Colesnicov -- Thanks -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-custom-JSON-in-a-livetable-tp7582208... Sent from the XWiki- Users mailing list archive at Nabble.com.
As a final - I found problem! When I setting livetable options need to write not only "rezultPage" parameter - by also and "className" parameter ... My working variant: ========= JSON page: ========= {{include document="XWiki.LiveTableResultsMacros" /}} {{velocity}} #if("$!{request.xpage}" == 'plain') $response.setContentType('application/json') #end #set($map = {}) #gridresult_buildJSON("$!request.classname" $request.collist.split(',') $map) #foreach($row in $map.get('rows')) #set($discard = $row.put('no', "$foreach.count")) #end $jsontool.serialize($map) {{/velocity}} =========== Livetable page =========== {{velocity}} #set($columns = [ "no" , "wIndex" , "wAlias" , "wName" , "wTeam" , "wActive" , "doc.date" , "_actions" ]) #set($columnsProperties = { "no" : { "type" : "text", "size" : 10, "filterable" : true, "sortable": true }, "wIndex" : { "type" : "text", "size" : 10, "filterable" : true, "sortable": true }, "wAlias" : { "type" : "text", "link" : "view", "size" : 10, "filterable" : true, "sortable": true }, "wName" : { "type" : "text", "link" : "view", "size" : 10, "filterable" : true, "sortable": true }, "wTeam" : { "type" : "text", "size" : 10, "filterable" : true, "sortable": true }, "wActive" : { "type" : "text", "size" : 10, "filterable" : true, "sortable": true }, "doc.date" : { "type" : "text", "size" : "10", "filterable" : true, "sortable": true }, "_actions" : { 'actions' : ['edit', 'delete'] } }) #set($options = { "className":"etvcPlanningsCode.wClass", "resultPage" : "etvcPlanningsCode.wJSON", "translationPrefix" : "w2.livetable.", "tagCloud" : true, "rowCount": 15, "maxPages" : 10, "selectedColumn" : "wIndex", "defaultOrder" : "asc" }) #livetable("w2" $columns $columnsProperties $options) {{/velocity}} -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-custom-JSON-in-a-livetable-tp7582208... Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (1)
-
Eugen Colesnicov