Hitachi Vantara Pentaho Community Wiki
Child pages
  • Using AJAX to Drive Dependent Report Parameters

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following code demonstrates this concept, using the example of Region driving Department selections, and Department driving Position Title selections:

Code Block

<script>
	      <![CDATA[

	     var regionControl = returnObjById("REGION");
	     regionControl.onchange=regionChangeFunction;

	     var deptControl = returnObjById("DEPARTMENT");
	     deptControl.onchange=departmentChangeFunction;

	     function departmentChangeFunction() {
	        paramService(new Array( "dept", deptControl.value, "solution", "samples", "path", "reporting/dep-param",
		                "action", "PositionTitlesForDept.xaction" ),
                      	"parseSOAPResultSet(\"POSITIONTITLE\", ", "");
	     }

	     function regionChangeFunction() {
	        paramService(new Array( "region", regionControl.value, "solution", "samples", "path", "reporting/dep-param",
	                     "action", "DepartmentsForRegion.xaction" ),
		    		   "parseSOAPResultSet(\"DEPARTMENT\", ", "departmentChangeFunction()");
	     }

	      ]]>

          </script>

Note that you now need another action sequence, to return to you the list of departments that you are requesting.

The Action Sequence as a Service: Querying for the List of Position Titles

Once the user chooses a department, we issue a call tot he ServiceAction, executing an action sequence that issues a query for the list of appropriate position titles. There is nothing fancy about this last action sequence, but I wanted to include a look at it here, so there is nothing left unclear.

  1. Open PositionTitlesForDept.xaction in Design Studio.
  2. You will see that the action sequence consists of one action, a SQL Lookup Rule, querying for the postion titles by the department that was passed in as an input parameter.

Image Added

Tweaking for Other Controls

If I haven't mentioned it yet, this code is written specifically geared toward combo boxes as the controls that we manipulate. You would have to tweak a bit of the code, notably the parseSOAPResultSet() function to get this to work with radio buttons, check boxes, etc.