How to process the data in the Livetable Checkbox Column Macro serviceDocument?

Hello!

Thanks for all the previous hints and help, unfortunately I can not fly by myself, so I ask again :slight_smile: :
https://extensions.xwiki.org/xwiki/bin/view/Extension/Add%20Checkbox%20Column%20To%20Livetable
How to process the data in the resulting serviceDocument?

Thank you in advance.

Hi!

Globally, I want to use Livetable with checkbox as a lookup table for displaying and setting data.

  1. How to organize data transfer and processing in the resulting serviceDocument?

  2. Can I redefine the serviceDocument (another space/name)?

  3. How to set checkboxes programmatically?

Does anyone have any working examples or can advise?

Thanks.

Hi!

Describe my efforts:

  1. After selecting several values ​​and pressing the “Send checkbox data” button, I see the following query:
    var formData = {
      "autputSyntax": "plain",
      "cbData": [
        "Alvaro",
        "Brandon"
      ],
      "xpage": "plain"
    };
    $.post('http://xwiki.censored.com/xwiki/bin/view/Code/ServiceDocument', formData)
      .done (showResult)
      .fail(showError);
    {
      "frameId": 0,
      "initiator": "http://xwiki.censored.com",
      "method": "POST",
      "parentFrameId": -1,
      "requestBody": {
        "formData": {
          "autputSyntax": [
            "plain"
          ],
          "cbData": [
            "Alvaro",
            "Brandon"
          ],
          "xpage": [
            "plain"
          ]
        }
      },
      "requestId": "375832",
      "tabId": 1612,
      "timeStamp": 1549962017587.2048,
      "type": "xmlhttprequest",
      "url": "http://xwiki.censored.com/xwiki/bin/view/Code/ServiceDocument"
    }
  1. I created a terminated page http://xwiki.censored.com/xwiki/bin/view/Code/ServiceDocument
  2. Added JavaScriptExtension object
  3. Entered this code:
    require(['jquery'], function ($) {
     var Target = $('#checkboxService')
     var Launcher = $('#GetJson')
     var Url = new XWiki.Document('cbResults','DatabaseInventory').getURL('get');
     var UrlParams = { 'xpage': 'plain','outputSyntax': 'plain' };
     Launcher.click(function(){
      $.get( Url, UrlParams, function( data ) {
        $( Target )
          .append( "Вибрано: " + data.cbData );
       }, "json" );
     });
    });

image

What else needs to be done, for example, to display the list of selected values ​​on the resulting page?

Thanks.

Hi!

At the moment I have been able to transfer data to ServiceDocument and get Response:

ServiceDocument code:

{{velocity wiki="false"}}

#set ($responseMessage = 'Slepping...')

## If AJAX call
#if("$!request.autputSyntax" != '')
  $response.setContentType('application/json')
  set ($responseMessage = 'Request detected')
#end

$responseMessage

{{/velocity}}

Response:

image

But I still do not know how to process the data in the sectionForm Data:
image

Any ideas?

Thanks…

Solved:

.......................................
{{addCheckboxColumnToLivetable livetable="hdwLookUpSoftware" column="softID" buttonId="sftCheckboxService" serviceDocument=$doc /}}
.......................................
#if("$!request.autputSyntax" != '')

    #set ($paramlist = '[')
    #foreach ($param in $request.getParameterValues("cbData"))
      #set ($paramlist = $paramlist + $param + ', ')
    #end
    #set ($paramlist = $paramlist + ']')
    #set ($paramlist = $paramlist.replace(', ]', ']'))
  
    $doc.set('hdwSoftware2', $paramlist)
    $doc.save()

  #end

Сode is ugly, but it works :slight_smile: