KoolReport's Forum

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

Repopulating dropdown lists #250

Open ingmar roos opened this topic on on Apr 17, 2018 - 4 comments

ingmar roos commented on Apr 17, 2018

I am developing a report where a user will select client's name from dropdown and based on the selected client which is select another dropdown list must be populated with the selected client's invoices.

I have not been able to dynamically populate the list containing invoice numbers of the selected client.

Can you please provide an example or tips how to solve this issue.

Thanks in advance

KoolReport commented on Apr 17, 2018

We have a perfect example for this, please have a look at Example of SubReport, Inputs and Ajax Report Loading.

The code of example can be found at downloaded package or in here

ingmar roos commented on Apr 24, 2018

Thank you very much for the reference:

I am still having a bit of trouble binding data and updating subreport when subReport.update method is called a variable "leping" should be set as parameter. However it does not. I have debugged by displaying this variable via window.alert and it is correctly collected from the combo box but when the subReport is updated it still behaves as if this parameter would be NULL. my code

<div class="form-group">
    <label>Vali klient:</label>
    <?php
    Select::create(array(
        "name"=>"lepingsel",
		"id"=>"lepingsel",
		"dataStore"=>$this->dataStore("kliendid"),
        "defaultOption"=>array("--"=>null),
		"dataBind"=>array(
                "text"=>"kliendinimi",
                "value"=>"lepinguid"
		),
		"clientEvents"=>array(
            "change"=>"function(){
                subReport.update('clientselecting',{
                    leping:$('#lepingsel').val(),
                });
                subReport.update('clientparcelslist');
				window.alert($('#lepingsel').val());
            }",
        ),
        "attributes"=>array(
            "class"=>"form-control",
        )
    ));
    ?>                
</div>

<?php
if($this->params["leping"])
{ // from here it behaves as the parameter is set to NULL

KoolReport commented on Apr 24, 2018

On the "change" event, you get the selected id from $('#lepingsel').val(), you should use it to update subreport for main part which I guess is clientparcelslist:

subReport.update('clientparcelslist',{
    leping:$('#lepingsel').val(),
});

In the sub report for clientparcelslist, you can get the $this->params['leping'] for further loading data.

ingmar roos commented on Apr 24, 2018

But first I need to populate the second dropdown list of my subreport and this part on code is not run because the parameter leping is not set and therefore a default value is still set.

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
None yet

None