On Mon, Jan 13, 2014 at 10:29 PM, Valdis Vītoliņš
<[email protected]> wrote:
> As LiveTable is document oriented and cant show several objects attached
> to the document, I have created customized JSON page
> following to guide in
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/LiveTable
>
> It even works for document name and space.
>

> But for other fields filtering stops working after 1-2 characters are
> entered. I suspect it is somehow related to AJAX requests which send
> partial data, because it works with get request
> /xwiki/bin/view/NMPDtools/ParticipantsJSONlivetable?firstname=Uldis

If it works fine when you access this URL separately, then I'd check
the requests that are made by the live table. Maybe it uses a
different URL. You can do this with most of the browser developer
tools.

Hope this helps,
Marius

>
> Any suggestions?
> Thanks!
>
> = LiveTable page =
> {{velocity}}
> #set($columns = [ "doc.name",
> "doc.space" ,"firstname"  ,"lastname"  ,"personid"  ,"certid" ])
> #set($columnsProperties = {
>       "doc.name" : { "type" : "text", "link" : "view", "size" : "10",
> "filterable" : true, "sortable": true, "displayName" : "Kurss" },
>       "firstname" : { "type" : "text", "size" : 10, "filterable" : true,
> "sortable": true },
>       "lastname" : { "type" : "text", "size" : 10, "filterable" : true,
> "sortable": true },
>       "personid" : { "type" : "text", "size" : 10, "filterable" : true,
> "sortable": true },
>       "certid" : { "type" : "text", "size" : 10, "filterable" : true,
> "sortable": true },
>       "doc.space" : { "type" : "text", "size" : "10", "filterable" :
> true, "sortable": true, "displayName" : "Organizācija" }
> })
>
> #set($options = {
> "className":"NMPDtools.ParticipantClass",
> "translationPrefix" : "livetable.",
> "tagCloud" : true,
> "rowCount": 15,
> "maxPages" : 10,
> "selectedColumn" : "doc.title",
> "defaultOrder" : "asc",
> "resultPage":"NMPDtools.ParticipantsJSONlivetable"
> })
>
> #livetable("participant" $columns $columnsProperties $options)
> {{/velocity}}
>
> = JSON results page =
>
> {{velocity filter="html" wiki="false"}}
> #if($xcontext.action == 'get' && "$!{request.outputSyntax}" == 'plain')
> $response.setContentType('application/json')
> #end
> ## Offset = item # at which to start displaying data
> #set($offset = $util.parseInt($request.get('offset')))
> ## offset starts from 0 in velocity and 1 in javascript
> #set($offset = $offset - 1)
> #if($offset < 0)
>  #set($offset = 0)
> #end
> ## Limit = # of items to display
> #set($limit = $util.parseInt($request.get('limit')))
> ## Sort direction
> #set($order = "$!request.sort")
> #if($order != '')
>  #set($orderDirection = "$!{request.get('dir').toLowerCase()}")
>  #if("$!orderDirection" != '' && "$!orderDirection" != 'asc')
>    #set($orderDirection = 'desc')
>  #end
> #end
> ##
> #set($doc_space=$request.getParameter('doc.space'))
> #set($doc_name=$request.getParameter('doc.name'))
> #set($firstname=$request.getParameter('firstname'))
> #set($lastname=$request.getParameter('lastname'))
> #set($personid=$request.getParameter('personid'))
> #set($certid=$request.getParameter('certid'))
> ##
> #set($hql="select doc.fullName, personid.id.value from XWikiDocument
> doc, BaseObject as obj, StringProperty firstname, StringProperty
> lastname, StringProperty personid where doc.fullName=obj.name and
> obj.className='NMPDtools.ParticipantClass' and obj.id=firstname.id.id
> and firstname.id.name='firstname' and obj.id=lastname.id.id and
> lastname.id.name='lastname' and obj.id=personid.id.id and
> personid.id.name='personid'")
> ##
> #if($doc_name && $doc_name!='')
> #set($hql="$hql and doc.name like '${doc_name}%'")
> #end
> #if($doc_space && $doc_space!='')
> #set($hql="$hql and doc.space like '${doc_space}%'")
> #end
> #if($firstname && $firstname!='')
> #set($hql="$hql and firstname.id.value like '${firstname}%'")
> #end
> #if($lastname && $lastname!='')
> #set($hql="$hql and lastname.id.value like '${lastname}%'")
> #end
> #if($personid && $personid!='')
> #set($hql="$hql and personid.id.value like '${personid}%'")
> #end
> ##
> ##$hql
> #set($results =
> $services.query.hql($hql).setLimit($limit).setOffset($offset).execute())
> {
> "totalrows":$results.size(),
> "matchingtags": {},
> "tags" : [],
> "returnedrows": $limit,
> "offset": $offset,
> "reqNo": $numbertool.integer($request.reqNo),
> "rows": [
> #foreach($item in $results)
> #set($partdoc=$xwiki.getDocument($item[0]))
> #if($partdoc.hasAccessLevel('view'))
> #set($partobj=
> $partdoc.getObject('NMPDtools.ParticipantClass','personid',$item[1]))
> $!d {"doc_viewable" : true,
> "doc_name":"$partdoc.name",
> "doc_url":"$xwiki.getURL($item[0])",
> "doc_space":"$partdoc.space",
> "firstname":"$partobj.firstname",
> "lastname":"$partobj.lastname",
> "personid":"$partobj.personid",
> "certid":"$partobj.certid"
> }
> #if(!$d)#set($d=',')#end
> #end
> #end
> ]
> }
> {{/velocity}}
>
>
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to