Hello All,
I have installed Kartik DateRangePicker and I’m unable to make it work with DynaGrid.
I have an "created" column into database which stores the dates I want to filter from(format YYYY-MM-DD).
in view index I have
[
'attribute' => 'created',
'format'=>'date',
'format'=>'raw',
'width'=>'300px',
'filterType'=> GridView::FILTER_DATE_RANGE,
'filterWidgetOptions' => [
'presetDropdown' => true,
'hideInput'=>true,
'pluginOptions' => [
'format' => 'YYYY-MM-DD',
'separator' => ' TO ',
'opens'=>'left',
],
]
],
and in model search function I have:
if(isset($this->created) && $this->created!=''){
$date_explode = explode("TO", $this->created);
$date1 = trim($date_explode[0]);
$date2 = trim($date_explode[1]);
$query->andFilterWhere(['between', 'created', $date1,$date2]);
}
But it seems that is not working. Setting date1 and date2 with fixed dates like 2016-01-01 filters results, so my guess is that the date range selected into index is not passed to the model.
Any ideas on how to achieve this?