KoolReport's Forum

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

DateTimePicker SubReport Clears Out From Field #1183

Open Jason opened this topic on on Nov 26, 2019 - 6 comments

Jason commented on Nov 26, 2019

I have a form with a subreport, I set the default From/To Date range, and also bind the min/max dates to each other. Then on change of a dropdown that calls an subreport update, i lose the To Date value, but not the From Date.

<div class="form-group"> 
	<div class="row">
		<div class="col-md-6">
			<strong>From Date:</strong>
			<?php
			DateTimePicker::create(array(
				"name"=>"startDatePicker",
				"maxDate"=>"@endDatePicker",
				"format"=>"MM/DD/YYYY h:mm A",
				"themeBase"=>"bs4",
			));
			?>
		</div>
		<div class="col-md-6">
			<strong>To Date:</strong>
			<?php
			DateTimePicker::create(array(
				"name"=>"endDatePicker",
				"minDate"=>"@startDatePicker",
				"format"=>"MM/DD/YYYY h:mm A",
				"themeBase"=>"bs4",
			));
			?>
		</div>
	</div>
</div>
<div class="col-md-6 form-group">
<strong>Trending Group</strong>
<?php
Select::create(array(
	"name"=>"trendTypeSelected",
	"dataStore"=>$this->dataStore("trendTypes"),
	"dataBind"=>"device",
	"attributes"=>array(
		"class"=>"form-control",
	),
	"clientEvents"=>array(
		"change"=>"function(){
			console.log('Testing change 1');
			subReport.update('trendselecting',{
/* 										startDatePicker:$('input[name=\"startDatePicker\"]').val(),
				endDatePicker:$('input[name=\"endDatePicker\"]').val(), */
				trendTypeSelected:$('#trendTypeSelected').val(),
			});
		}",
	)
));
?>
</div>

KoolReport commented on Nov 29, 2019

Have you set up binding between "startDatePicker" widget and the parameter of report?

Jason commented on Dec 2, 2019

Yes I have. In binddefaultparameter and settingDefaultValues.

//Set Default Param Values
protected function defaultParamValues(){
	
	//Set Current EST DateTime Minus 1 Hour For Default Trending Range
	$startDate = date('m/d/Y h:i A' , strtotime( '-1 hour' ));

	//Current EST DateTime Minus 1 Hour For Default Trending Range
	$endDate = date('m/d/Y h:i A');
	error_log("START DATE " . $startDate);
	error_log("END DATE " . $endDate); 
    return array(
        "startDatePicker"=>$startDate,
        "endDatePicker"=>$endDate,
        "trendTypeSelected"=>"AC",
        "trendsToView"=>array("---","---"),
    );
}

This is bound in the Primary preport (TrendSelecting) and the DatePicker is actually part of the sub report(TrendViewing)

KoolReport commented on Dec 2, 2019

I mean binding parameter to inputs with bindParamsToInputs() method. If possible, please send you code to support@koolreport.com, I would like to see if I can spot something.

Jason commented on Dec 2, 2019

//Map Inputs to Form Parameters

protected function bindParamsToInputs()
{
    return array(
        "trendTypeSelected",
        "trendsToView",
        "startDatePicker",
        "endDatePicker",
    );
}

Sorry, yes i did bind them there as well.

iWorQ Systems commented on Dec 8, 2022

I know this was 3 years ago, but I am having the exact same issue with mine. Was there any progress on this?

Sebastian Morales commented on Dec 9, 2022

KoolReport's DrillDown/SubReport uses ajax(xhr) requests. If you have problem with parameters pls open browser dev tool (F12), tab Network, label XHR and click on Drilldown/SubReport. Then check the xhr request in dev tool to see its value and response. If any parameter (such as end date) is missing, consider adding it to the drilldown/update command. For example:

			subReport.update('mySubReport',{
                            ...
                            endDate: '<?php echo $this->params["endDate"]; ?>'
			}); 

Let us know your finding. Tks,

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