Greetings,
Newbie here. I have a form with 2 textfields with datepicker to choose a begining and ending dates of events, a bootsrap tabular to show 2 CGridViews (there are 2 types of events both have different models, so each tab has one model) and a button to search.
(and yes, I must have those datepickers as the standard CGridView filtering is not to be used on this page)
The thing is in my action I get the begining and ending dates from the $_POST, perform Active Record query and then send the model back.
However, I apparently lost pagination in the process and am a bit lost on what to do.
My first CGridView (the other is the same but from a different model so I will ignore it):
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'event-grid',
'dataProvider'=>$searching,
'columns'=>array(
array(
'name'=>'main_sponsor',
'htmlOptions'=>array('style' => 'text-align: center;')
),
array(
'name'=>'starting_date',
'htmlOptions'=>array('style' => 'text-align: center;')
),
array(
'name'=>'ending_date',
'htmlOptions'=>array('style' => 'text-align: center;')
),
.....
),
));
As you can see, im using this ‘dataProvider’=>$searching, which is probably the issue as it is a regular model. Anyway, I’m getting it by doing this on my controller:
$searching = new CActiveDataProvider('Event', array(
'criteria'=>array(
'condition'=>'starting_date >= :converted_start_date AND starting_date <= :converted_ending_date',
'params'=>array(':converted_start_date'=>$converted_start_date , ':converted_ending_date'=>$converted_ending_date),
));
Then when I visit the page, I can see the total number of results, and the pagination, but when I click to the next page, the hole CGridView disappears. Any tips?
Thanks for you input,
Regards