KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Using Filter with a parameter #1136

Open Daniel Amamoo-Otchere opened this topic on on Oct 24, 2019 - 5 comments

Daniel Amamoo-Otchere commented on Oct 24, 2019

Hello Kool Team,

I have a dataset node which is used to build another dataset node2 with some filters. How do I apply a different paramter using the Filter option only for that dataset.

$node->pipe($this->dataStore("result"));

     $node ->pipe(new Filter([
		['id','in','(:__pid__)']
	  ])) 

Is the way I have defined the filter correct.

The records will come from another datasource not part of the main datasource found in $node

but part of the defaultParams value and bindParamsToInputs functions

KoolReport commented on Oct 24, 2019

it is just an array of ids for example

->pipe(new Filter([
    ['id','in',[1,2,3,4]]
]))
Daniel Amamoo-Otchere commented on Oct 25, 2019

ok I mean can I use a variable like $id in replacement to the array [1,2,3,4,5]. this is because that is also coming from another parameter

KoolReport commented on Oct 25, 2019

Yes, if you have parameter in array form like $ids containing all ids you want to see, you replace with my [1,2,3,4,5] array. The MultiSelect widgets or Select2 multiple can output parameters in array form when your user select a list of ids, you may use them in the view.

Daniel Amamoo-Otchere commented on Oct 25, 2019

Still not so sure how to handle this :

Below is the select control. How do I pass it to the "dataStore"=>$this->dataStore("student_trend") below.


<form>	
        <center><b>Performance per class child </b></center>
	          <h5>Select Level:</h5><?php
                        Select::create(array(
                            "name"=>"pStudent",
							"multiple"=>true,
							"dataStore"=>$this->dataStore("ds_students"),
                             "dataBind"=>array(
                                "text"=>"name_string",
                                "value"=>"students_id",
                        )));
                        ?>
			</form>		
   <?php
             ColumnChart::create(array(
         	"options"=>array(
					    "title"=> 'Performance Charts',
						"width"=> '100%',
						"height"=> '100%',
						"legend"=>array("position"=> "right"),
						),
						  "dataStore"=>$this->dataStore("student_trend")->FILTER("students_id","IN ",),
            ));  
	
KoolReport commented on Oct 25, 2019

You should use the Select2, this allow multiple selection, the Select only allow single selection. So if you have a parameter "pStudent" that binds to your "pStudent" Select2 multiple. You will do this:

->pipe(new Filter([
    ['id','in',$this->params["pStudent"]]
]))

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Inputs