How can I use Cascading Input Controls in the REST PHP API?

0

Hi,

I can call reports with parameterised input controls from jasperserver in my php without any problems but what I can't figure out how to do is implement cascading input controls properly.

For example, say I have I/P Control A with values of A1, A2 and I/P Control B with values of A1b1 and A1b2 if I/P Control A has A1 selected or values of A2b1 and A2b2 if I/P Control A has A2 selected. I cannot get this to replicate in the php api. I/P Control A will generate with A1 and A2 and I/P Control B will generate with A1b1 and A1b2 (ie the A1 values) but I can't force it to reload to A2b1 and A2b2 if A2 is selected. Has anyone figured this out? I've looked at the Input Control JSON structure and there is a field called "slaveDependencies" but I can't figure out how to take advantage of that. How can I call an input control to regenerate based on the value of its master control?

Thanks in advance!

jasperUser12's picture
Joined: May 23 2014 - 4:52pm
Last seen: 3 years 4 months ago

I got it working but I had to write a new function in the wrapper.

public function setCascadingInputControls($uri, $controls, $payload)
    {  
        // $controls is masters;active;slaves/
        $url = $this->restUrl2 . '/reports' . $uri . '/inputControls/' . $controls . '/values';
        $data = $this->service->prepAndSend($url, array(200), 'POST', $payload, true, 'application/json', 'application/json');
        // Can use the InputControl createFromJSON() function as structure is the same.
        //print($data);
        return InputControl::createFromJSON($data);
    }
  1. The $controls object has to be defined as follows : "masterDependencies;currentControlSelected;slaveDependencies"
  2. The $payload object has to be an array of objects with the key as the control id and the value as (a possible array of) the selected option(s).
jasperUser12 - 4 years 10 months ago

0 Answers:

No answers yet
Feedback